Issue
I am making e-commerce website on ( React.js - client )and ( Python Django - client ). I am trying to make a search feature for list of all products and the queries are none-english. Whenever I try to search, my none-english query gets into hell knows what. For example I input query "текст" and it turns to / search / %D1%82%D0%B5%D0%BA%D1%81%D1%82. Expected: / search / текст.
And of course my api cannot find any product with this query..
@api_view(["GET"])
def searchData(request, q):
searchedData = Product.objects.filter(Q(title__icontains=q))
data = ProductSerializer(searchedData, many=True).data
return Response(data)
This is my search view.
path('search/<str:q>/', views.searchData)
This is my path.
I hope for any kind of help. Thanks!
Solution
The %D1%82%D0%B5%D0%BA%D1%81%D1%82
in fact is текст
, but is url encoded, you have to decode it.
You can verify this on this page https://www.urldecoder.io/
Answered By - Angel Hdz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.