Django admin - How can I add the green plus sign for Many-to-many Field in custom admin form

后端 未结 2 1333
一向
一向 2020-12-11 07:12

The green plus sign button for adding new instances in the admin form disappears for my MultiSelect field (photos) when I define it in my form. Ie, removing the line with th

2条回答
  •  醉话见心
    2020-12-11 07:34

    Yes you are right, you have to wrap your widget with django.contrib.admin.widgets.RelatedFieldWidgetWrapper, which turns out to be a bit complicated since it expects the current admin site as a parameter for initialization! Maybe you will find this post helpful!

提交回复
热议问题