The Django Admin
The Django admin is an automatically generated, production-ready web interface that lets you create, read, update, and delete your model data through a browser, with no extra code beyond registering your models.
Learn The Django Admin in our free Django course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a quick reference.
Part of the free Django course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
In this lesson you'll enable the admin, create a superuser to log in, register your first model so it appears in the interface, and then customise the list view to make managing data fast and pleasant.
The admin is enabled by default in a fresh project — django.contrib.admin is already listed in INSTALLED_APPS , and the /admin/ route is wired up in your project's urls.py . Before you can log in, you need to run migrations and create an administrator account.
After logging in you'll only see the built-in Users and Groups sections. To manage your own data, you register a model in your app's admin.py file. A single call to admin.site.register gives you full add, edit, list, and delete pages.
Suppose you have a Post model in blog/models.py :
Refresh /admin/ and a Posts section appears. The __str__ method matters here: it controls the label Django shows for each row, so Post object (1) becomes the actual post title.
A bare registration works, but the list page only shows the __str__ value. To control which columns appear, add filters, a search box, and an auto-filled slug, you define a ModelAdmin subclass and attach it with the @admin.register decorator.
Fill in the blank so the function builds the correct registration line for a model named Post .
You never registered it, so the admin doesn't know it exists.
✅ Fix: add admin.site.register(YourModel) (or the @admin.register decorator) in the app's admin.py .
No administrator account exists yet, or you forgot the password.
✅ Fix: run python manage.py createsuperuser to make an account (after migrate ).
❌ The admin page itself won't load (404 or no apps)
Your app isn't installed, so its models and migrations are ignored.
✅ Fix: add your app to INSTALLED_APPS in settings.py , then run migrate .
Write a helper that takes a list of fields and prints a ready-to-paste list_display line for a ModelAdmin class.
Lesson 6 complete — you can manage data through the admin!
You enabled the admin, created a superuser, registered a model so it appears in the interface, and customised the list view with a ModelAdmin class using list_display, list_filter, search_fields, and prepopulated_fields.
🚀 Up next: Models & Migrations — design the database tables that power everything you just managed in the admin.
Practice quiz
How do you create an administrator account for the admin?
- python manage.py runserver
- python manage.py createsuperuser
- python manage.py migrate
- python manage.py startadmin
Answer: python manage.py createsuperuser. createsuperuser prompts for a username, email, and password and creates a full-permission account.
Which call registers the Post model so it appears in the admin?
- admin.site.register(Post)
- admin.add(Post)
- Post.register()
- site.install(Post)
Answer: admin.site.register(Post). admin.site.register(Post) adds the model to the admin so it gets auto-generated CRUD pages.
Which decorator registers a model with a custom ModelAdmin class?
- @admin.site
- @register.model
- @admin.register(Post)
- @modeladmin(Post)
Answer: @admin.register(Post). @admin.register(Post) above a ModelAdmin subclass registers the model with that customisation.
Which ModelAdmin option chooses the columns shown in the list view?
- search_fields
- list_filter
- prepopulated_fields
- list_display
Answer: list_display. list_display is a tuple of field names that become the columns in the change list.
What must you run before createsuperuser so the auth tables exist?
- collectstatic
- migrate
- makemigrations only
- test
Answer: migrate. The superuser is stored in auth_user, so you must run migrate first to create the tables.
Which ModelAdmin option adds a search box over named fields?
- list_display
- list_filter
- search_fields
- ordering
Answer: search_fields. search_fields is a tuple of fields the admin search box queries.
Why might your model not appear in the admin?
- You never registered it
- You ran migrate twice
- You created a superuser
- You used ModelAdmin
Answer: You never registered it. A model only appears after admin.site.register or the @admin.register decorator.
Which option auto-fills a slug field from the title?
- list_display
- list_filter
- search_fields
- prepopulated_fields
Answer: prepopulated_fields. prepopulated_fields = {'slug': ('title',)} auto-fills the slug from the title as you type.
What controls the label shown for each row in the admin list?
- The model's id
- The first CharField
- The model's __str__ method
- list_filter
Answer: The model's __str__ method. The __str__ method gives each object a readable name in the admin.
Which ModelAdmin option adds a filter sidebar?
- search_fields
- list_filter
- list_display
- prepopulated_fields
Answer: list_filter. list_filter adds a sidebar of filters for the named fields.