Django comes with a background management site, to help us manage the data. This interface is only used by administrators, is not open to the public.
Create an administrator user
py manage.py createsuperuser
As shown below:
- Username not fill it, use the default administrator name
- E-mail can not fill
- Enter the password in the process it will not be displayed. If your password is strong enough, it will warn you if you want to use that password. Because 1234567890 I entered, so you feel ok, then yes it will direct you through.
Start the development server, and enter the admin interface
py manage.py runserver
After the server is started, enter in your browser http://127.0.0.1:8000/admin , enter the login screen
Enter just registered an account, enter the site management page
Groups (group) above and the Users (user) can be edited, which is provided, which is authentication framework Django development. django.contrib.auth
Added to the voting application management page
We need now polls / admin.py register, the application will be able to see the polls in the management interface. code show as below:
# polls/admin.py
from django.contrib import admin
from .models import Question
admin.site.register(Question)
Refresh the page, you can see the Question class.
Functional admin site
We registered the issue Question class to the management page, it we can add, delete, change and other operations.
Click on "Questions". Now we see the problem "Questions" list of objects "change list". This screen displays all the database objects in the problem Question, you can select one to modify. Here now we have created in the previous section "What's up?" Question.
Click on "What's up?" To edit this question (Question) Object: