python / beginner
Snippet
Customizing the Admin List View
The list_display attribute in a ModelAdmin class allows you to specify which model fields are shown as columns in the admin change list page.
snippet.py
1
2
3
4
5
6
7
from django.contrib import adminfrom .models import Article@admin.register(Article)class ArticleAdmin(admin.ModelAdmin):list_display = ('title', 'status', 'created_at')list_filter = ('status',)
django
Breakdown
1
@admin.register(Article)
Connects the Article model to this custom admin configuration.
2
list_display = (...)
Defines the columns visible in the main table of the admin panel.