Answer the question
In order to leave comments, you need to log in
How to create an autocomplete field with django-autocomplete-light?
Can't create autocomplete field (python3.8, django3.0)
Here is view/urlpatterns/widget on form
class ProgrammingLanguageAutocompleteView(autocomplete.Select2QuerySetView):
def get_queryset(self):
if self.q:
qs = ProgrammingLanguage.objects.filter(value__istartswith=self.q)[:10]
else:
qs = ProgrammingLanguage.objects.all()
return qs
path(
'programming-language-autocomplete',
ProgrammingLanguageAutocompleteView.as_view(),
name='programming_language_autocomplete'
),
widgets = {
'programming_language': autocomplete.ModelSelect2(url='programming_language_autocomplete')
}
{"results": [{"id": "13298", "text": "Python", "selected_text": "Python"}], "pagination": {"more": false}}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question