Native way to preview results in Django?

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?

By 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 users type, 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.

Вернуться на верх