DjangoAdmin Inline with list of links to children, not their forms. Is it possible?

18 views
Skip to first unread message

IL Ka

unread,
Dec 17, 2017, 7:43:21 AM12/17/17
to Django users
Hello.
I have categories and objects and object has foreign key to the category.

I want to give user ability to open category in admin and see list of objects.

``StackedInline`` along with ``show_change_link = True`` solves it. However, it displays form for every single object in category. My object has 10 fields rendering this UI unusable.
What I want to have:

Category1 Page:
* Category Form itself
* List of objects:
* Object1 [change] [edit]
* Object2 [change] [edit]
...
* ObjectN [change] [edit]
* [add new]

Is it possible? 

Ilya.


Ramez Ashraf

unread,
Dec 17, 2017, 11:24:39 AM12/17/17
to Django users
Yes it is.. but it might require some hacks .
The idea is to provide the List of children objects as an initial to the formset being created.
Till 1.11 there was no "clean" way to do it.. you have to override the _create_formsets on model admin
You may also need to filter those initials so there is no duplication in the case of /change as opposed to the add.

Good luck
Reply all
Reply to author
Forward
0 new messages