Use Admin Site Day13

Suppose we want to design a news site, we need to write a page displayed to the user, displayed on the web page news information come from? It is to look for information from the database to the news, and then show it on the page . But the news on our web site will be updated daily, which means that the database add, delete, change, search operations, then we need to write the sql statements to manipulate database every day? If so, is not very complicated, so we a page can be designed to achieve the additions and deletions to the database through the operation of the news page of this change search operation. So the question is, the boss said we need to build a new website, are we going to design a page to achieve the new site additions and deletions to change search database operations, but this page has a lot of repetitive, that there is not a method allows us to quickly generate a database page management table it? Yes, that is what we are going to tell you next Django management background . Django can automatically generate the model page management class definition.

Use Django management module, need to follow the following steps:

  1. Localization Management Interface
  2. Create an administrator
  3. Sign up model class
  4. Custom Management page

1 management interface localization

Set language and time zone in the settings.py

LANGUAGE_CODE = 'zh-hans' # 使用中国语言
TIME_ZONE = 'Asia/Shanghai' # 使用中国上海时间

2 Create a Super Admin

Creating an administrator command as follows, enter the user name, email, password.

python manage.py createsuperuser

 

Open the browser, enter in the address bar enter the following address.

http://127.0.0.1:8000/admin/

Enter the user name you created earlier, complete the login password

Guess you like

Origin blog.csdn.net/qq_42370150/article/details/104716529