修改polls包里面的apps.py:
from django.apps import AppConfig
class PollsConfig(AppConfig):
name = 'polls'
verbose_name = '投票'
修改polls包里面的models.py:
from django.db import models
# Create your models here.
# 在我们的polls应用程序中,
# 将创建两个模型:Question和Choice,
# Question有一个问题和一个出版日期,
# Choice有两个领域:选择的文本和票数,
# 每个Choice都关联一个Question
class Question(models.Model):
question_text = models.CharField(max_length=200, verbose_name='问题文本')
pub_date = models.DateTimeField('出版日期')
def __str__(self):
return self.question_text
class Meta:
verbose_name = '问题'
verbose_name_plural = '问题'
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200, verbose_name='选择文本')
votes = models.IntegerField(default=0, verbose_name='选票')
def __str__(self):
return self.choice_text
class Meta:
verbose_name = '选择'
verbose_name_plural = '选择'
python manage.py runserver
启动
自定义中文站点
在polls包里面的admin.py增加:
admin.site.site_title = "测试平台"
# 修改标题
admin.site.site_header = "测试部门"
# 修改页眉