Class Signature
AdminChangeListTab provides a nested changelist interface within a tab, allowing you to display and manage related objects inline. Unlike AdminTab, it shows a list of related objects rather than form fields.
Class Attributes
Optionally specify a custom display name for this admin tab. If not provided, the class name will be used.
The parent model that this changelist tab is nested under. Set automatically by
TabbedModelAdmin.The specific instance of the parent model being viewed. Set automatically by
TabbedModelAdmin.The field path to filter the queryset for the changelist given the parent_object. Can use full Django ORM paths (e.g.,
"product" or "order__customer"). For more advanced queryset filtering, override get_queryset().The ContentType field name when using generic foreign keys. Only used if
fk_field is not set.The object ID field name when using generic foreign keys. Only used if
fk_field is not set.Optional form class for bulk operations on the changelist. When provided, a bulk action form is displayed below the changelist.
The template used for rendering the add form within the nested changelist.
The template used for rendering the change form within the nested changelist.
The template used for rendering the changelist within the tab.
Methods
get_tab_name()
str - The tab name from admin_tab_name if set, otherwise the class name.
get_tab_slug()
str - A slugified version of the tab name.
get_queryset()
request- The Django HttpRequest object
QuerySet - Filtered queryset containing only objects related to the parent object
Behavior:
- If
fk_fieldis set, filters by that foreign key relationship - Otherwise, uses ContentType generic foreign key with
ct_fieldandct_fk_field
save_model()
request- The Django HttpRequest objectobj- The model instance being savedform- The ModelForm instancechange(bool) - True if updating existing object, False if creating new
This method automatically handles setting the foreign key or generic foreign key relationship to the parent object.
get_changelist()
request- The Django HttpRequest object**kwargs- Additional keyword arguments
type - A ChangeList subclass with custom url_for_result() method
get_changelist_form()
request- The Django HttpRequest object**kwargs- Additional keyword arguments
type - Form class for the changelist
process_view()
changelist_view().
Parameters:
request- The Django HttpRequest objectobject_id- The ID of the parent objectextra_context(dict | None) - Optional additional context
HttpResponse
changelist_view()
request- The Django HttpRequest objectobject_id- The ID of the parent objectextra_context(dict | None) - Optional additional context
HttpResponse
Features:
- Adds “Add” button URL to context
- Processes
change_list_bulk_formif provided - Displays success messages for bulk operations
response_add()
request- The Django HttpRequest objectobj- The newly created object
HttpResponseRedirect
Behavior:
- “Save and add another” → Redirects to add view
- “Save as new” → Redirects to change view for new object
- Default → Redirects to change view for new object
response_change()
request- The Django HttpRequest objectobj- The modified object
HttpResponseRedirect
Behavior:
- “Save and add another” → Redirects to add view
- “Save and continue editing” → Redirects back to change view
- Default → Delegates to parent implementation
response_delete()
request- The Django HttpRequest objectobj_display(str) - String representation of deleted objectobj_id- ID of the deleted object
HttpResponseRedirect - Redirects back to the changelist tab
response_post_save_change()
request- The Django HttpRequest objectobj- The modified object
HttpResponseRedirect - Redirects back to the changelist tab
response_post_save_add()
request- The Django HttpRequest objectobj- The newly created object
HttpResponseRedirect - Redirects back to the changelist tab
get_model_perms()
request- The Django HttpRequest object
dict - An empty dictionary