ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

Django Tutorial• 7 min read

The Built-in Django Admin Dashboard

Configuring model administration, filters, search fields, and permissions

One of Django's most celebrated superpowers is its built-in, production-ready admin interface. By reading your model metadata, Django auto-generates a CRUD administrative portal with zero frontend code required.

Customizing the ModelAdmin Interface

python manage.py createsuperuser: Prompts for username, email, and password to grant full system administrative access.

admin.site.register(Model, ModelAdmin): Registers a model to appear in the /admin/ portal.

list_display: Controls which columns appear in the table view.

search_fields: Adds an instant text search bar querying indexed fields.

list_filter: Adds sidebar filter pills for dates, booleans, and relational categories.

Customizing admin.py for Course Management
from django.contrib import admin
from .models import Course, Category

@admin.register(Course)
class CourseAdmin(admin.ModelAdmin):
    list_display = ('title', 'category', 'price', 'is_published', 'created_at')
    list_filter = ('is_published', 'category', 'created_at')
    search_fields = ('title', 'description')
    list_editable = ('price', 'is_published')
    ordering = ('-created_at',)

@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('title',)}
list_editable allows instructors and admins to change prices directly from the overview list view.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

Which ModelAdmin attribute specifies the columns displayed in the admin records table view?