Eight, Admin

1, backstage entrance
  HTTP: // 127.0.0.1 : 8000 / ADMIN /

2, create user command
  Python manage.py createsuperuser # add a user
  can enter the admin page to add


3 to achieve backstage management table
  PS: When you create a database, field verbose_name write Chinese name, Chinese name admin page appears
  operation subproject files below admin.py
from . Import Models   # Import Database Tables 
# the Register your Models here Wallpaper. 
# written on these two, you can see and manage tables in the admin page 
admin.site.register (models.Nav)
admin.site.register(models.Article)

4, the implementation details of the management table
admin.py in
from django.contrib import admin
from . import models
# Register your models here.

class ArticleAdmin(admin.ModelAdmin):
    list_display = [ ' ID ' , ' title ' , ' IMG ' , ' NAV ' ] # display multiple columns, table inside the field name 
search_fields = [ ' title ' , ' Content ' ] # depending on which search field 
list_per_page =. 5 # Per several data display page 
list_filter = [ ' NAV ' ]

admin.site.register(models.Article,ArticleAdmin)

 

Guess you like

Origin www.cnblogs.com/yanyan-/p/11743982.html