Search code examples
pythondjangodjango-autocomplete-light

Django-autocomplete-light textwidget display all the values before typing


I use django-autocomoplete-light to make an autocopmlete-field for tags. I decided to use TextWidget for my form because with ChoiceWidget I can't get the value from web-page. The problem is that when input field is activating, the values displays immediately in the drop-down. The ChoiceWidget works a little bit different. It starts display the values only when some characters are inputed.


Solution

  • Since you didn't provide some code I don't know exactly how your autocomplete registry code looks like, but specifying the minimum amount of characters to 0 does the trick.

    Slightly modified example from the docs:

    import autocomplete_light.shortcuts as al
    
    al.register(your_model,
        attrs={
            'data-autocomplete-minimum-characters': 0,
        },
    )