1 Creating an admin user
$ python manage.py createsuperuser
UserName: wuwh
Password: ganbare
2 Start the development server¶
$ python manage.py runserver 8088
visit :http://127.0.0.1:8000/admin/
3 .Make the poll app modifiable in the admin
from django.contrib import admin # Register your models here. from .models import Question,Choice #3.第三版 class ChoiceInline(admin.TabularInline): model = Choice extra = 3 class QuestionAdmin(admin.ModelAdmin): #1.第一版 #fields = ['pub_date','question_text'] #2.第一版 fieldsets=[ (None,{'fields':['question_text']}), ('Date information',{'fields':['pub_date'],'classes':['collapse']}), ] inlines = [ChoiceInline] list_display = ('question_text','pub_date','was_published_recently') list_filter = ['pub_date'] search_fields = ['question_text'] admin.site.register(Question,QuestionAdmin)