创建用户:
python manage.py createsuperuser
image.png
怎么把我们的app放到管理员界面进行管理?
在polls/admin.py文件中进行修改。
from django.contrib import admin
from .models import Question
# Register your models here.
admin.site.register(Question)
image.png
点进去一看:
image.png
发现polls下有了Question这个对象:
image.png
from django.db import models
# Create your models here.
class Question(models.Model):
#Create char type attribute in DB, which length is 200,name is question_text.
question_text = models.CharField(max_length=200)
#Create time type attribute in DB, which name is pub_date
pub_date = models.DateTimeField('date published')
image.png
把polls/models.py中pub_date = models.DateTimeField('date published')的'date published'删除得到pub date。
image.png
查看history可得:
image.png