Admin Page
Subscribe to Tech with Tim
Django Admin Page
You may have noticed in previous tutorials that there exists a link to a page called "admin". In this tutorial we will cover what this page is used for and how to register our database so that we can login and view it from here.
Creating an Admin Login
If you navigate to the django admin page you will notice that it asks you for some login information. However, right now we have no login. To create a login we need to navigate to the directory containing migrate.py and run the following command: python manage.py createsuperuser
Once you have created a user run the server by running python manage.py runserver and navigate to the "admin/" address. Here you can use your login information to login.
You should see a page that looks like this:
Adding Our Database
This page is meant to show us (the admin) information about our site and database. To add our database to this dashboard we need to modify the admin.py file from within our app directory.
from django.contrib import admin from .models import ToDoList, Item # Register your models here. admin.site.register(ToDoList) admin.site.register(Item)
Now if we save our changes and refresh the site we should see our databases added.