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.
# 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.