Django's admin auto-generates a staff UI for CRUD on registered models—huge productivity win for internal tools and early-stage products.
Registering models
from django.contrib import admin
from .models import Article
@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
list_display = ["title", "published", "created_at"]
list_filter = ["published"]
search_fields = ["title"]
Setup
- Ensure
django.contrib.adminin INSTALLED_APPS - Run migrations (admin tables included)
python manage.py createsuperuser- Visit
/admin/
Important interview questions and answers
- Q: Admin for public users?
A: No—staff-only internal tool; build custom views or SPA for customers. - Q: Customize admin?
A: ModelAdmin options, inlines, actions, custom templates—or third-party packages like django-grappelli. - Q: Permissions?
A: Django auth integrates—users need is_staff and model permissions.
Self-check
- Which file registers models with admin?
- What command creates the first admin login?
Tip: list_display, search_fields, and list_filter are the first three ModelAdmin upgrades—staff productivity jumps immediately.
Interview prep
- Admin for customers?
No—the admin is staff-only; build custom views or a SPA for end users.