The Django admin
Register models and turn the admin into a useful internal tool.
What you will be able to do
- Register models in admin.py.
- Use list_display and list_filter.
- Add search_fields for quick lookup.
- Restrict admin access to staff users.
In plain English
The admin is a production-quality internal interface generated from your models. Register models with list displays, filters and search so staff can work without custom screens. It is not the public UI.
from django.contrib import admin
from .models import Course, Lesson
@admin.register(Course)
class CourseAdmin(admin.ModelAdmin):
list_display = ('title', 'slug', 'created_at')
search_fields = ('title', 'slug')
@admin.register(Lesson)
class LessonAdmin(admin.ModelAdmin):
list_display = ('title', 'course', 'minutes', 'published')
list_filter = ('published', 'course')Your turn
EasyAdd a search field
Make the admin search lessons by title.
PYTHON · starter
search_fields = ()Check your understanding before moving on.
Knowledge checkQuestion 1
What is the Django admin best used for?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.