我很难将它们集成在一起,当访问“/autocomplete/CartaoAutocomplete/”时,我得到“相关字段的查找无效:icontains”。相关代码:
模型.py
class Cartao(models.Model):
...
tags = TaggableManager()
autocomplete_light_registry.py
...
autocomplete_light.register(Cartao,
search_fields=['tags'],
)
表格.py
...
class CartaoForm(ModelForm):
tags = TagField(widget=TagWidget('CartaoAutocomplete'))
管理员.py
...
class CartaoAdmin(admin.ModelAdmin):
form = autocomplete_light.modelform_factory(Cartao)
admin.site.register(Cartao, CartaoAdmin)