Django--admin, models 사용자 정의 이름 추가

2290 단어 django
어디서부터 말해야 할지 모르겠다
코드를 직접 보려면 다음과 같이 하십시오.
models.py
#coding=utf-8

from django.db import models
from django.contrib import admin

# Create your models here.
class Guys(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=40)
    email = models.EmailField()
    def __unicode__(self):
        return u'%s %s' % (self.first_name, self.last_name)
    class Meta:
        verbose_name = '    '
        verbose_name_plural = '    '
    
class Equipname(models.Model):
    name = models.CharField(max_length=100)
    def __unicode__(self):
        return u'%s' % self.name
    class Meta:
        verbose_name = '      '
        verbose_name_plural = '      '

class Equipstatus(models.Model):
    name = models.ForeignKey(Equipname)
    fru = models.CharField('FRU', max_length=30)
    pn = models.CharField('PN', max_length=30, blank = True)
    sn = models.CharField('SN', max_length=30, blank = True)
    out = models.BooleanField('  ', default = False)
    tempout = models.BooleanField('  ', default = False)
    describe = models.CharField(u'  ', max_length=100, null = True)
    warehouse_people = models.ForeignKey(Guys, verbose_name = u'   ')
    warehouse_time = models.DateField(verbose_name = '    ')
    def __unicode__(self):
        return u'%s' % self.name
    class Meta:
        verbose_name = '      '
        verbose_name_plural = '      '
        app_label = u"    "  
        db_table = 'app_dc_equipstatus'#       

class profileAdmin(admin.ModelAdmin):
    list_display = ('name', 'fru', 'describe',)
    search_fields=('name__name', )
    #    Django admin             “related Field has invalid lookup: icontains”  
    #                    。         model
    #               。              "      __          "。

admin.py
#coding=utf-8

from django.contrib import admin
from app_DC.models import Guys, Equipstatus, Equipname, profileAdmin

admin.site.register(Guys)
admin.site.register(Equipname)
admin.site.register(Equipstatus, profileAdmin)

마지막 거 주의.

좋은 웹페이지 즐겨찾기