← Django tutorial

Django

The Admin Site

Registering a model with Django's admin gives you a working create/read/update/delete interface at /admin/, with zero extra HTML to write.

Example: registering a model with the admin

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

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ('title', 'published_at')
Visiting /admin/ now shows a "Posts" section listing every post's
title and publish date, editable in the browser.

This is exactly the mechanism behind every "an admin approves this" workflow on a real platform, a course going live only after review, a tutor's application being approved, all handled through ModelAdmin classes just like this one, sometimes with custom admin actions (a button that runs a specific bit of Python against selected rows) added on top for things like "approve selected." The admin site is meant for trusted staff, not public-facing use, it isn't a substitute for the actual public pages your visitors see.

Example
# blog/admin.py
from django.contrib import admin
from .models import Post

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ('title', 'published_at')
Output
Visiting /admin/ now shows a "Posts" section listing every post's title and publish date, editable in the browser.
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Closes Nov 30

Enroll in Backend Development

Cookie preferences

Choose what you're comfortable with. You can change this any time from the footer.

Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account