I have a django app running(frontend is vanilla everything) and it has a search function. I would like for users to see a preview dropdown of search results while typing so that they can know if there will be results without having to complete the search, to increase UX. Is there a django package or a native django method to do this? And what is this called?
I have a django app running(frontend is vanilla everything) and it has a search function. I would like for users to see a preview dropdown of search results while typing so that they can know if there will be results without having to complete the search, to increase UX. Is there a django package or a native django method to do this? And what is this called?
Share Improve this question asked Feb 6 at 16:03 tthheemmaanniitthheemmaannii 3491 silver badge10 bronze badges1 Answer
Reset to default 1By default don't show any data on the dropdown, let user type something and then fetch the data based on user input, the filter at backend may be something like -
MyModel.objects.filter(field__startswith=user_typed_value)
Now you will have to fetch the data based on each letter (keystroke) that the user types, again this is not a very good design, as it will do a lot of database queries so use DebounceValue. you can read more about this.
Also you can read more about Autocomplete UI component.
Also select max 10 - 12 objects on the filter query. (a rough estimate)