入門3:后臺(tái)管理

創(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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容