You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
juyaolongpaul edited this page Apr 16, 2018
·
2 revisions
Django offers us another way interacting with the database, and it is through the admin page. The URL (urls.py within the folder mysite) of the admin page is added automatically once you start a project:
url('admin/', admin.site.urls)
So that once you attach admin/ to the link of the homepage, an admin page will be displayed, requiring you to log in as a superuser to manage the site. The detailed content of the admin page is defined in admin.py within blog folder.
# Register your models here.fromdjango.contribimportadminfrom .modelsimportPost, Commentadmin.site.register(Post)
admin.site.register(Comment)
By default, you can see the registered users and groups, which is the built-in functions that the admin page already has. If you want to manage the models and the instances you define, you need to register the model using admin.site.register(MODEL_NAME), then the model will be able to view and edit in the admin page.