Django Admin

Django's admin interface is auto-generated from your models — no extra code needed.

Register your model

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

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ['title', 'author', 'published', 'created_at']
    list_filter = ['published', 'created_at']
    search_fields = ['title', 'content']
    prepopulated_fields = {'slug': ('title',)}

Create a superuser

Bash
python manage.py createsuperuser
# Follow the prompts

Visit http://localhost:8000/admin — you'll see a fully functional admin interface with CRUD operations for every registered model.

Tips

  • Admin is great for content management and data inspection.
  • Use list_display, list_filter, and search_fields to customise.
  • Never use admin for production user-facing forms — build custom views.

Next: auth.