The Road to WeChat Mini Program Development (9) Django Admin Management Tool

The Road to WeChat Mini Program Development (9) Django Admin Management Tool

Django provides web-based management tools.
The Django automated management tool is part of django.contrib. You can see it in the INSTALLED_APPS in the project's settings.py: Insert picture description here
django.contrib is a huge set of functions, which is part of the basic Django code.
Activation management tool
Usually we will automatically set it in urls.py when generating the project, we only need to remove the comment.
The configuration items are as follows:

from django.conf.urls import url
from django.contrib import admin
 
urlpatterns = [
    url(r'^admin/', admin.site.urls),
]

Insert picture description here
When all this is configured, the Django management tool is ready to run.
Start the development server, and then visit http://127.0.0.1:8000/admin/ in the browser to get the following interface:
Insert picture description here
You can create a super user through the command python manage.py createsuperuser, as shown below:
Insert picture description here
Insert picture description here
In order to let the admin interface manage a certain A data model, we need to register the data model to the admin first. For example, we have created the model Test in TestModel before. Modify TestModel/admin.py: After
Insert picture description here
refreshing, you can see the Testmodel data table:
Insert picture description here

Guess you like

Origin blog.csdn.net/xulei1132562/article/details/113649020