在执行django后台管理时,登陆到http://127.0.0.1:8000/admin/,进入页面后没有对应的字段显示。请解决?
代码:
models.py
from django.db import models # Create your models here. #发布会表 from django.db import models class Event(models.Model): name = models.CharField(max_length = 100) #发布会标题 limit = models.IntegerField() #参加人数 status = models.BooleanField() #状态 address = models.CharField(max_length = 200) #地址 start_time = models.DateTimeField('events time') #发布会时间 create_time = models.DateTimeField(auto_now = True) #创建时间 def __str__(self): return self.name #嘉宾表 class Guest(models.Model): event = models.ForeignKey(Event) #关联发布会ID realname = models.CharField(max_length = 64) #姓名 phone = models.CharField(max_length = 16) #手机号 email = models.EmailField() #邮箱 sign = models.BooleanField() #签到状态 create_time = models.DateTimeField(auto_now = True) #创建时间,自动获取当前时间 class Meta: unique_together = ('event','phone') def __str__(self): return self.realname # Create your models here. from django.conf import settings class Article(models.Model): """文章""" STATUS_CHOICES = ( ('d', '草稿'), ('p', '发表'), ) COMMENT_STATUS = ( ('o', '打开'), ('c', '关闭'), ) TYPE = ( ('a', '文章'), ('p', '页面'), ) title = models.CharField('标题', max_length=200, unique=True) body = models.TextField('正文') pub_time = models.DateTimeField('发布时间', blank=True, null=True) status = models.CharField('文章状态', max_length=1, choices=STATUS_CHOICES, default='p') comment_status = models.CharField('评论状态', max_length=1, choices=COMMENT_STATUS, default='o') type = models.CharField('类型', max_length=1, choices=TYPE, default='a') views = models.PositiveIntegerField('浏览量', default=0) author = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='作者', on_delete=models.CASCADE) article_order = models.IntegerField('排序,数字越大越靠前', blank=False, null=False, default=0) def __str__(self): return self.title class Meta: ordering = ['-article_order', '-pub_time'] verbose_name = "文章" verbose_name_plural = verbose_name get_latest_by = 'created_time'
admin.py
from django.contrib import admin from sign.models import Event,Guest # Register your models here. admin.site.register(Event) admin.site.register(Guest)
登陆显示页面如下:
实际应该显示:
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Django模型中的admin后台管理无法显示字段 - Python技术站