Search⌘ K
AI Features

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:

Python
from django.contrib import admin
# Register your models here.

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:

Python
from django.contrib import admin
from .models import House
from .models import Checker
# Register your models here.
admin.site.register(House)
admin.site.register(Checker)
  • Lines 3–4: We import our House and Checker models from houses.models.

  • Lines 8–9: We call on the ...