当在另一个下拉列表上进行选择时,如何在 Django 的管理员中过滤下拉列表 [英] How to filter a dropdownlist in Django's admin when a selection is made on another dropdownlist

查看:17
本文介绍了当在另一个下拉列表上进行选择时,如何在 Django 的管理员中过滤下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Django 管理站点中有两个下拉列表.例如,我有 SelectCountry 和 SelectRegion.Region 与 Country 有外键关系.如何确保在选择国家/地区时,根据该国家/地区过滤区域?

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?

注意:我也在使用 django-grappelli 作为我的管理后端.

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

任何想法都会受到赞赏.谢谢.

Any ideas will be appreciated. Thanks.

推荐答案

正如 DrMeers 所暗示的,使用 django-smart-selects.重新发明轮子没有意义.

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

这篇关于当在另一个下拉列表上进行选择时,如何在 Django 的管理员中过滤下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆