Hi Ahmed, Here is my code:
*Views.py* *class DatasetListAPIView(ListAPIView): serializer_class = DatasetlSerializer def get_queryset(self): qs = Dataset.objects.all() word = self.request.query_params.get('word') if word is not None: qs = qs.filter(name__icontains = word).order_by(Length('name').asc(),'-hits') return qs search_fields = ('name',)* but if my end user type something like: http://127.0.0.1:8000/search/?word = a then I want to show some database match record suggestion like: http://127.0.0.1:8000/search/?word = an http://127.0.0.1:8000/search/?word = at http://127.0.0.1:8000/search/?word = ant I think I need to override inbuilt HTML and Javascript,But I don't know How to do that Please tell me How I can do that. Thank You for your response Regards, Soumen On Thu, Aug 22, 2019 at 5:43 PM Ahmed Shahwan <a...@shahwan.me> wrote: > you'll just create an endpoint that receives a query parameter with the > string to search for, and you'll search using > YOURMODEL.objects.get(field=query_params.get("search_str")) > > the frontend will be responsible for making the requests to search while > typing > so, in your views.py you'll do something like this: > > > > from rest_framework.views import APIView > from rest_framework.response import Response > > > from .models import YourModel > > > class Search(APIView): > def get(self, request): > search_str = request.query_params.get("search_str") > results = YourModel.objects.get(field_to_search=search_str) > return Response({"results": results}) > > > > you'll tie it to a route in urls.py file > > and you're good to go > > > On Thursday, August 22, 2019 at 10:08:38 AM UTC+2, Soumen Khatua wrote: >> >> Hi Folks, >> >> I want to give some sequence of suggestion after type of any character(of >> course if that character match any sequnce of string in database record) in >> search query parameter, How I can do that by using Django Rest framework. >> Plase help me guys. >> >> >> Thank You >> >> Regards, >> Soumen >> > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/c6c4f40c-3a2f-4dfc-a310-8e7f17a79827%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/c6c4f40c-3a2f-4dfc-a310-8e7f17a79827%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6Wb2fJS3Bizx2KNa3FF08ys3FPKbs_nJCfh9UNXNmzc%2BYQ%40mail.gmail.com.