The Admin Site

Django ships with a full, password-protected admin dashboard, generated automatically from your models — no HTML, no views, no forms of your own required to get a working "add, edit, delete, search" interface.

Creating a superuser

The admin site needs an account to log in with:

Terminal
python manage.py createsuperuser
Output
Username: admin
Email address: admin@example.com
Password:
Password (again):
Superuser created successfully.

django.contrib.admin is already in INSTALLED_APPS and already wired into urls.py by default (path('admin/', admin.site.urls), generated for you back in lesson 2) — so visiting /admin/ and logging in with this account already works, before you've registered a single model of your own.

Registering a model

By default, the admin site only shows Django's own built-in models (like users). To manage your own, register them explicitly:

Python blog/admin.py
from django.contrib import admin
from .models import Post

admin.site.register(Post)

Reload /admin/ and "Posts" now appears in the dashboard, with a full list view, an "Add Post" form generated from the model's fields, search, and delete — all without writing any HTML.

Customizing the list view

The default list view just shows each row's __str__(). A ModelAdmin class lets you control exactly what columns and filters appear:

Python blog/admin.py
from django.contrib import admin
from .models import Post

class PostAdmin(admin.ModelAdmin):
    list_display = ('title', 'published', 'created_at')
    list_filter = ('published',)
    search_fields = ('title',)

admin.site.register(Post, PostAdmin)

list_display adds columns to the table view instead of just the title, list_filter adds a sidebar for filtering by that field, and search_fields adds a search box that searches those fields. None of this touches your model — it's purely about how the admin presents it.

Note: the admin site is a genuinely useful internal tool, not just a demo feature — plenty of real Django projects use it as-is for staff to manage content, with no custom dashboard ever built. It's not meant to be exposed to your site's regular visitors, though; it's for people you trust with direct database-level access.