1👍
✅
The following registers an Autocomplete for “Cartao”, which means that it will suggest “Cartao” objects. And what you are trying to do is an Autocomplete to suggest tags, which are Tag instances. Instead of this:
# autocomplete_light_registry.py
autocomplete_light.register(Cartao,
search_fields=['tags'],
)
# forms.py
class CartaoForm(ModelForm):
tags = TagField(widget=TagWidget('CartaoAutocomplete'))
You should have:
# autocomplete_light_registry.py
from taggit.models import Tag
autocomplete_light.register(Tag)
# forms.py
class CartaoForm(ModelForm):
tags = TagField(widget=TagWidget('TagAutocomplete'))
Let me know if this is correct then I will update the documentation.
👤jpic
Source:stackexchange.com