...
/Accessing Migration Tables in Django
Accessing Migration Tables in Django
Learn how to view database tables from the Django administration 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:
Press + to interact
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:
Press + to interact
from django.contrib import adminfrom .models import Housefrom .models import Checker# Register your models here.admin.site.register(House)admin.site.register(Checker)
Lines 3–4: We import our
House
andChecker
models fromhouses.models
.Lines 8–9: We call on the
admin.site.register
to ...