最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

search - Native way to preview results in Django? - Stack Overflow

programmeradmin1浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

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 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)

发布评论

评论列表(0)

  1. 暂无评论