- Configuring the Admin Path in the urls.py file
from Import URL from Import Admin from Import = [ url (r'^admin/', admin.site.urls), URL (r '^$', index, name='index')]
- Configure the database to be displayed in the background in the admin.py file
from Import Admin from Import *# Register your models here. Admin.site.register (User) admin.site.register (TAG) admin.site.register (article) Admin.site.register (catagory) Admin.site.register (Comment) admin.site.register (Links) admin.site.register (Ad)
- Create a background Super Admin account by entering ' manage.py creatsuperuser ' on the command line
- manage.py Runserver, run the local server.
(blog_project_venv) d:\python\blog_project>manage.py runserverperforming System checks ...2016-05-26 23:34:24,711 [dummy-1:13568] [django.db.backends:89] [Utils:execute] [debug]-(0.000) SET SQL_AUTO_IS_NULL = 0; args=Nonesystem Check identified no issues (0 silenced).2016-05-26 23:34:24,779 [dummy-1:13568] [django.db.backends:89] [Utils:execute] [debug]-(0.000) SET SQL_AUTO_IS_NULL = 0; args=None2016-05-26 23:34:24,779 [dummy-1:13568] [django.db.backends:89] [Utils:execute] [debug]-(0.000) SHOW full TABLES; args=None2016-05-26 23:34:24,779 [dummy-1:13568] [django.db.backends:89] [Utils:execute] [debug]-(0.000) SELECT ' Django_ Migrations '. ' app ', ' django_migrations '. ' Name ' from ' django_migrations '; args=() may26, 2016-23:34:24Django version1.9.6, using Settings'blog_project.settings'starting Development Server at http:127.0.0.1:8000/Quit the server with CTRL-break.
- Enter the configured path in the browser ' 127.0.0.1:8000/admin ' into the admin background management interface, enter the created Super Administrator account, into the background.
- Various configurations in the background can be made in admin.py
#-*-coding=utf-8-*- fromDjango.contribImportAdmin fromModelsImport*#Register your models here.classArticleadmin (admin. Modeladmin):#Customizing article ClassesList_display = ('title','desc','Click_count',)#let the data appear by default in the backgroundList_display_links = ('title','desc',)#let the data be connected and modifiedList_editable = ('Click_count',)#allow ' click_count ' to be modified directly #Fields = (' title ', ' desc ', ' content ') #让 ' article ' in the background only displays ' title ', ' desc ', ' content ' options #exclude = (' title ', ' desc ', ' content ') #让 ' article ' does not show ' title ', ' desc ', ' content ' option in the background #fieldsets = (#将 ' article ' category display #(none,{#将要显示的数据 #' Fields ': (' title ', ' desc ', ' content ') # }), #(' Advanced settings ', { #' classes ': (' collapse ',), #将数据显示隐藏 #' Fields ': (' click_count ', ' is_recommend ') # }), # )Admin.site.register (User) admin.site.register (TAG) admin.site.register (article, articleadmin)#add articleadmin into the backgroundAdmin.site.register (catagory) admin.site.register (Comment) admin.site.register (Links) admin.site.register (Ad )
Long March second Step--django personal blog (Fifth Step--configure admin in background)