您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

自定义django的管理员以具有相关的选择字段

自定义django的管理员以具有相关的选择字段

您可能要使用django smart selects中的分组选择功能。从自述文件

如果您具有以下模型:

class Location(models.Model)
    continent = models.ForeignKey(Continent)
    country = models.ForeignKey(Country)

并且您希望所有国家/地区都按洲分组,并且希望在对以下内容的选择更改中使用组:

from smart_selects.db_fields import GroupedForeignKey

class Location(models.Model)
    continent = models.ForeignKey(Continent)
    country = GroupedForeignKey(Country, "continent")
Go 2022/1/1 18:48:02 有270人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶