Get a full database management UI for free. Create a superuser, register your models, and customize the list and edit screens to make the admin genuinely useful.
Why: the admin requires a user with staff access; createsuperuser makes an all-powerful account. Note: this works only after the first migrate (which creates the auth tables). Then run the server and open /admin/.
Answer the username / email / password prompts:
python manage.py createsuperuserpython manage.py runserverWhy: a model does not appear in the admin until you register it. When the @admin.register decorator: the modern way — it pairs a model with its admin configuration class in one place. Where: blog/admin.py.
# blog/admin.py
from django.contrib import admin
from .models import Post, Tag
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
pass
admin.site.register(Tag) # the simple form, no customizationWhy: by default the list shows only __str__. list_display turns it into a useful table; list_filter adds a sidebar of filters; search_fields adds a search box; prepopulated_fields auto-fills the slug from the title as you type.
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
list_display = ["title", "author", "status", "created_at"]
list_filter = ["status", "created_at", "author"]
search_fields = ["title", "body"]
ordering = ["-created_at"]
list_editable = ["status"] # edit inline from the list
prepopulated_fields = {"slug": ("title",)} # slug follows the title
date_hierarchy = "created_at"Note: Django creates four permissions per model — add, change, delete, view. A Group bundles permissions so you can assign them in one click (e.g. an "Editors" group). is_staff lets a user into the admin; is_superuser bypasses every permission check.
# in the shell or a data migration
from django.contrib.auth.models import Group, Permission
editors = Group.objects.create(name="Editors")
editors.permissions.add(
Permission.objects.get(codename="add_post"),
Permission.objects.get(codename="change_post"),
)
user.groups.add(editors) # user now inherits those permissions
user.has_perm("blog.add_post") # True