Long March second Step--django personal blog (Fifth Step--configure admin in background)

Source: Internet
Author: User

  1. 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')]

  2. 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)

  3. Create a background Super Admin account by entering ' manage.py creatsuperuser ' on the command line
  4. 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.

  5. 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.
  6. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.