Customizing ModelAdmin
Set list_display, list_filter, and search_fields.
Customizing ModelAdmin is a free Django Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Django Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Beyond the Defaults
The default admin works but feels plain. A ModelAdmin class lets you reshape how each model looks and behaves in the admin.
Subclass and Attach
Create a class that subclasses admin.ModelAdmin, then pass it when you register the model. That class holds all your tweaks.
class PostAdmin(admin.ModelAdmin):
pass
admin.site.register(Post, PostAdmin)Columns in the List
The list page shows one column by default. Set list_display to a tuple of field names and the admin renders each as a column.
list_display = ("title", "author", "created")Filter the Sidebar
Big tables get hard to scan. Add list_filter and the admin shows a sidebar to narrow rows by those fields fast. 🔍
list_filter = ("status", "created")Add a Search Box
Let staff hunt for records by text. Setting search_fields puts a search bar at the top that scans those fields.
search_fields = ("title", "author__name")Click to Edit
By default only the first column links to the edit page. Use list_display_links to choose which columns are clickable instead.
list_display_links = ("title",)Edit Inline in the List
Want to change a value without opening each row? Put a field in list_editable and you can edit it right on the list page.
list_editable = ("status",)Prefill the Slug
Slugs are tedious to type. The prepopulated_fields option fills a slug live from the title as you type it. ⚡
prepopulated_fields = {"slug": ("title",)}Order the Rows
Control the default sort with ordering. A leading minus sorts that field descending, so newest items can lead the list.
ordering = ("-created",)Group the Form
Long edit forms feel cluttered. Use fieldsets to split fields into labeled, collapsible sections on the edit page.
Computed Columns
list_display can also call a method on your admin class. That lets you show derived values, like a short preview of the body.
def short(self, obj):
return obj.body[:30]Quick Check
Which option controls the columns shown on the list page?
Recap
With ModelAdmin you added columns, filters, search, and sorting. A few attributes turn a plain table into a powerful data console. 🛠️
Frequently asked questions
Is the “Customizing ModelAdmin” lesson free?
Yes — the full text of “Customizing ModelAdmin” is free to read here on the web, and the Django Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Django Academy course, upgrade to CoddyKit PRO.
What will I learn in “Customizing ModelAdmin”?
Set list_display, list_filter, and search_fields. You practise Django Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Django Academy?
No prior experience is required. Django Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Customizing ModelAdmin” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Django Academy lesson?
Yes. Every Django Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.