創(chuàng)建用戶:
python manage.py createsuperuser
image.png
怎么把我們的app放到管理員界面進(jìn)行管理?
在polls/admin.py文件中進(jìn)行修改。
from django.contrib import admin
from .models import Question
# Register your models here.
admin.site.register(Question)
image.png
點(diǎn)進(jìn)去一看:
image.png
發(fā)現(xiàn)polls下有了Question這個(gè)對(duì)象:
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