简体   繁体   中英

Not able to select many to many in Django admin as right selection pane not visible

I have a model which contains ManyToMany relationship. But when I go to admin and want to add object from admin, the right pane where selection goes is not visible.

django管理员

In order to select many to many fields and see them in a right pane, you should add filter_horizontal to your admin class:

admin.py

class TheModelAdmin(admin.ModelAdmin):
    filter_horizontal = ['the_name_of_the_field']


admin.site.register(TheModel, TheModelAdmin)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM