I've installed django-autocomplete-light
and am trying to get it to work.
I have it on the (non admin) form, but when I try to actually change the value, I get a 500 error as above.
AttributeError at /autocomplete/SeriesAutocomplete/
'list' object has no attribute 'startswith'
Here are some relevant files:
autocomplete_light_registry.py
:
import autocomplete_light
from models import Series
class SeriesAutocomplete(autocomplete_light.AutocompleteModelBase):
search_fields = ['^title',],
attrs = {'placeholder': 'Series name ?',}
autocomplete_light.register(Series, SeriesAutocomplete)
forms.py
:
class PublicationForm(ModelForm):
series = autocomplete_light.ModelChoiceField('SeriesAutocomplete')
class Meta:
model = Publication
fields = ['title', 'series', 'dsn', 'primary_contact', 'department']
I must be missing something??
It's just a simple typo, you wrote
search_fields = ['^title',],
Which made search_fields
a tuple of lists. Removing the comma should work.
search_fields = ['^title',]