将 Django smart_selectors与django_cities_light一起使用不起作用

using django smart_selectors with django_cities_light not working

提问人:Aijaz Mahdavi 提问时间:11/15/2023 最后编辑:Aijaz Mahdavi 更新时间:11/15/2023 访问量:22

问:

我正在使用 django cities_light,但我想要的是:区域下拉列表取决于国家和城市下拉列表。

为了实现这一点,我安装了smart_selectors来使用 ChainedForeignKey 调情他们,奇怪的是,它第一次起作用,但当我前几天检查它时,它不会再拧动了。

这是我正在使用的代码

from smart_selects.db_fields import ChainedForeignKey
from cities_light.models import Country, City, Region

    
    Class Address(Models.Model):
        
    #i tried this before did not work
    #country = models.ForeignKey('cities_light.Country', #on_delete=models.SET_NULL, null=True,         #blank=True)
    
        # Country, City and State
        country = models.ForeignKey(Country, on_delete=models.CASCADE, null=True)
        
    
        region = ChainedForeignKey(
            Region,
            chained_field="country",
            chained_model_field="country",
            show_all=False,
            auto_choose=True,
            null=True
        )
    
        city = ChainedForeignKey(
            City,
            chained_field="state",
            chained_model_field="region",
            show_all=False,
            auto_choose=True,
            null=True
        )

我正在附上屏幕截图

他们不会以某种方式被束缚,我不知道我做错了什么

我把他们带到了连锁和 fliter 地区,然后是城市 xD

我在终端日志中得到这个

“获取 /chaining/filter/cities_light/地区/国家/联系人/地址/地区/8/ HTTP/1.1” 404 6160

python django django-models

评论


答: 暂无答案