here is my code.
class op_ViewSet(viewsets.ModelViewSet) : http_method_names = ['get'] queryset = Op.objects.all().filter() serializer_class = op_Serializer pagination_class = MyPagination filter_backends = [DjangoFilterBackend , SearchFilter , OrderingFilter] filter_class = op_filter search_fields = ['website' , 'title' , 'description' , 'organization__name']
search_fields search for keywords in the website, title, description, and organization column of a table.
this is how I sent the postman request.
http://127.0.0.1:8000/?search=Belgian,Services
right now my code performs an end operation. it returns me those rows which contain both the Belgian, Services keywords whereas I want that it returns those rows which contain only Belgian, only services, or both of them in any of its 4 columns I provided on search-fields.
how can I achieve it?
your help is much appreciated. I tried this enter link description here but it didn't work for me
https://stackoverflow.com/questions/66830043/how-to-do-or-operations-with-django-rest-framework-search-filter-instead-of-and March 27, 2021 at 05:59PM
没有评论:
发表评论