Rest framework autocomplete

59 views
Skip to first unread message

Soumen Khatua

unread,
Aug 19, 2019, 11:45:27 PM8/19/19
to django...@googlegroups.com
Hi guys,
 I want to implement autocomplete options like if someone type 'a' if it is contains in between any data it should provide the suggestion of the matched words. Then it will return first 25 matched data, how I can do that by using django rest framework. Please help me with source code.

Thank you in advance

Regards,
Soumen

Abu Yusuf

unread,
Aug 20, 2019, 12:03:38 AM8/20/19
to django...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WYDQP5YgDZcHC_e8_c%2BTbs3CNEuxutFtmcvmZF-gqu2xA%40mail.gmail.com.

Soumen Khatua

unread,
Aug 20, 2019, 12:56:32 AM8/20/19
to django...@googlegroups.com
My query is little bit different suppose I type A in the search box imtjen it should recommend AAA, ABC if they are exist into the database. How I can do that?? 

Andréas Kühne

unread,
Aug 20, 2019, 3:56:29 AM8/20/19
to django...@googlegroups.com
Hi,

This is exactly what you do with filtering and pagination? Could you please specify why it doesn't suit your usecase? I need to understand more to actually be able to help you :)

Regards,

Andréas


DANIEL URBANO DE LA RUA

unread,
Aug 20, 2019, 4:04:07 AM8/20/19
to django...@googlegroups.com
You will need to load the data first and for the rest use javascript 

Soumen Khatua

unread,
Aug 20, 2019, 4:15:15 AM8/20/19
to django...@googlegroups.com
Suppose If I'll type 'A' and database contains some sentences as an example AABC, ABC, BCA.It should suggest all the names those are contains A. If I need to javascript then I can configure could you tell me please. 

Thank you for your response. 

Andréas Kühne

unread,
Aug 20, 2019, 4:22:55 AM8/20/19
to django...@googlegroups.com
Ok - so what you need to do is configure the endpoint to use the filters and pagination. Then you need to connect to the backend with javascript and populating the results by adding to the dom.

Here is something that is more or less what you want to do - however you need the backend code to get this to work:

Regards,

Andréas


Soumen Khatua

unread,
Aug 20, 2019, 5:05:55 AM8/20/19
to django...@googlegroups.com
Could you tell me how can I configure javascript in my rest api apps. Actually I'm new to this area.

Thank you 

Andréas Kühne

unread,
Aug 20, 2019, 5:20:07 AM8/20/19
to django...@googlegroups.com
If you read the article I sent you he goes through the javascript side and what you need to do on that side. However the endpoint URL you need to decide yourself - thats the part restframework helps you with.

Regards,

Andréas


Reply all
Reply to author
Forward
0 new messages