3

When I register autocomplete_light.AutocompleteModelBase and use it in my form, the results that are shown are always limited to 20. I can't find any option in the docs to increase the number of results that gets displayed on the form.

autocomplete_light_regisrty.py

class IssueAutocomplete(autocomplete_light.AutocompleteModelBase): model = Issue search_fields = ('^issue_number',) autocomplete_light.register( IssueAutocomplete, attrs={ 'placeholder': 'Type an issue number...', 'data-autocomplete-minimum-characters': 1 }, ) 

forms.py

class StoryForm(autocomplete_light.ModelForm): class Meta: model = Story fields = ('slug', 'summary', 'author', 'editor', 'issue',) 

But when I search my form, only a maximum of 20 results appear, even though I have well over 60. This is replicated when I go to /autocomplete/IssueAutocomplete. Only 20 results appear at a time.

How do I get a full list of resuls?

3
  • 2
    limit_choices ? Commented Dec 9, 2015 at 16:34
  • You are correct. It used to be limit_results. Thanks you. Commented Dec 9, 2015 at 16:35
  • Ok, I post it as answer. Commented Dec 9, 2015 at 16:35

2 Answers 2

5

You should to use limit_choices as is described in documentation.

Sign up to request clarification or add additional context in comments.

Comments

4

By default AutocompleteModelBase has the attribute named limit_choices which by default is set tot 20. You can overwrite it with a new value to expand it. Although not documented, if you want no limit pass -1 as the attribute is only to slice the results

2 Comments

I accepted danihp answer because he commented first. But thank you for the addition of -1, that will be useful in the future.
yea! nice link to source code ;) Also appreciated by me.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.