Reputation: 350
I would like to be able to collapse and expand object details when showing objects in the django admin change list view.
For example, for an order, I would like the order list to first appear as:
+ id: 1, name: John Smith
+ id: 2, name: Jane Doe
And then when the user expands one order:
- id: 1, name: John Smith
address: 321 Oaktree Drive, LA, CA
+ id: 2, name: Jane Doe
inline objects won't work, because the order does not have a foreign key to itself. If anyone could point me in the right direction, it would be greatly appreciated.
Upvotes: 2
Views: 1198
Reputation: 129964
You can override/extend both the template (ModelAdmin.change_list_template
) and the view (ModelAdmin.changelist_view
). The original view accepts extra_context
, so you can easily add whatever you need. See contrib.admin documentation for more details.
Upvotes: 1