What is AdminChangeListTab?
AdminChangeListTab is a specialized class that creates a tab displaying a filtered changelist (list view) of related objects within a parent model’s admin interface. Unlike AdminTab which shows forms, AdminChangeListTab shows a table of related records that can be added, edited, and managed inline.
This allows you to work with related models without leaving the parent object’s admin page, creating a seamless nested admin experience.
When to Use AdminChangeListTab
UseAdminChangeListTab when you need to:
- Display a list of related objects as a tab (e.g., all orders for a customer)
- Manage one-to-many or many-to-many relationships in a separate tab
- Filter and display objects related through foreign keys
- Work with generic relations (using ContentType framework)
- Provide full CRUD operations for related objects without page navigation
Key Attributes
The display name for the tab. If not specified, the class name will be used.
The model class of the parent object this changelist is nested under. This is used for URL generation and context.
The specific parent object instance. This is set automatically by
TabbedModelAdmin at runtime.The field path to filter the queryset for the changelist given the parent object. Supports full Django ORM paths like
"choice__poll".For more advanced filtering, override the get_queryset() method instead.The field name for the ContentType foreign key when using generic relations. Only used if
fk_field is not specified.The field name for the object ID when using generic relations. Only used if
fk_field is not specified.Optional form class for bulk operations on the changelist. Enables custom bulk actions.
How Nested Changelists Work
Automatic Filtering
When you define anAdminChangeListTab, it automatically filters the related model’s queryset to show only objects related to the parent:
Automatic Relationship Assignment
When saving objects in a nested changelist, the parent relationship is automatically set:Code Example
Here’s a real example from the Django Admin Tabs source code:AnswerAdmindisplays all answers related to a poll through thechoice__pollrelationship- The
fk_fielduses Django ORM path notation to traverse the relationship - The form is customized to only show choices from the current poll
- All standard Django admin features like
date_hierarchyandlist_displaywork normally
Filtering by Parent Object
Simple Foreign Key
For direct foreign key relationships:Traversing Relationships
For relationships through intermediate models:Generic Relations
For generic foreign keys (without specifyingfk_field):
Known Limitations
Workaround for Deletion
To handle deletion in nested changelists, you can:- Use bulk actions instead of individual delete buttons
- Override the
delete_viewmethod to customize behavior - Implement custom delete actions in your changelist
Advanced Usage
Custom Queryset Filtering
Overrideget_queryset() for complex filtering logic:
Bulk Action Forms
Add custom bulk operations withchange_list_bulk_form:
URL Routing
AdminChangeListTab automatically generates URLs for:
- Changelist view:
/admin/{app}/{model}/{id}/tabs/{tab}/ - Add view:
/admin/{app}/{model}/{id}/tabs/{tab}/add/ - Change view:
/admin/{app}/{model}/{id}/tabs/{tab}/{nested_id}/change/ - Delete view:
/admin/{app}/{model}/{id}/tabs/{tab}/{nested_id}/delete/
TabbedModelAdmin and handle all navigation automatically.
Related Concepts
- AdminTab - For custom form tabs instead of changelists
- TabbedModelAdmin - The parent admin class that orchestrates tabs