Accessing Migration Tables in Django
Explore how to register models in Django's admin.py file and create a superuser account to access and manage migration tables through the Django administration dashboard. Understand the process of logging in, viewing, and modifying database tables such as Houses and Checkers, and managing user permissions within the admin site.
We'll cover the following...
To see our database tables and fields on the Django admin page, we have to register our models in the admin.py file and also create a superuser.
Registering models
To register our model, let’s open the houses/admin.py file. Inside it, we'll see a boilerplate that imports the admin from django.contrib, as shown below:
The first line imports the admin from django.contrib, while the last line is a comment.
Then, we register our models by importing them and calling the admin.site.register to register our respective models:
Lines 3–4: We import our
HouseandCheckermodels fromhouses.models.Lines 8–9: We call on the ...