首页 > 解决方案 > django-smart-selects 无法正常工作

问题描述

我想在我的 django-admin 中链接外键,因此我正在使用 django-smart-selects。我已正确遵循文档

  1. 安装 django-smart-selects
  2. 将其添加到 settings.py 中的 installed_apps
  3. 在我的基本 urls.py 中添加这一行
       url(r'^chaining/', include('smart_selects.urls')),
  1. 相应地改变了我的模型:
class AddressModel(BaseModel):
    country = models.ForeignKey(CountryModel, null=True, blank=True, on_delete=models.PROTECT)
    state = ChainedForeignKey(StateModel, chained_field=country, chained_model_field=country,
                              null=True, blank=True, on_delete=models.PROTECT)
    city = models.CharField(max_length=200, null=True, blank=True)

并将其添加到我的 setting.py

JQUERY_URL = True

但是每次我尝试从管理员创建地址时,都会收到此错误:-

if path.startswith(('http://', 'https://', '/')): AttributeError: 'bool' 对象没有属性 'startswith'

如何解决这个问题?

标签: pythondjangodjango-modelsdjango-admindjango-smart-selects

解决方案


在 settings.py 中使用USE_DJANGO_JQUERY = True而不是JQUERY_URL = True


推荐阅读