How to filter a dropdownlist in Django's admin when a selection is made on another dropdownlist

自作多情 提交于 2019-12-19 05:46:09

问题


I have two dropdownlists in a Django admin site. For example, I have SelectCountry and SelectRegion. Region has a foreignkey relationship to Country. How do I ensure that when a Country is selected, the Regions are filtered based on that Country?

N.B: I am using django-grappelli for my admin backend as well.

Any ideas will be appreciated. Thanks.


回答1:


As DrMeers hints at, use django-smart-selects. No point in re-inventing the wheel.



来源:https://stackoverflow.com/questions/9853595/how-to-filter-a-dropdownlist-in-djangos-admin-when-a-selection-is-made-on-anoth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!