[英]Not able to select many to many in Django admin as right selection pane not visible
I have a model which contains ManyToMany relationship. 我有一个包含ManyToMany关系的模型。 But when I go to admin and want to add object from admin, the right pane where selection goes is not visible. 但是,当我进入admin并想从admin添加对象时,选择所在的右窗格不可见。
In order to select many to many fields and see them in a right pane, you should add filter_horizontal
to your admin class: 为了选择多对多字段并在右窗格中查看它们,您应该将filter_horizontal
添加到您的管理类中:
admin.py
class TheModelAdmin(admin.ModelAdmin):
filter_horizontal = ['the_name_of_the_field']
admin.site.register(TheModel, TheModelAdmin)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.