Django-rest-framework will has a SearchFilter backend that will allow a single query against the searchable fields:
class OrganizationViewSet(viewsets.ModelViewSet):
queryset = Organization.objects.all()
serializer_class = OrganizationSerializer
pagination_class = CustomPagination
filter_backends = (filters.SearchFilter, DjangoFilterBackend)
filter_fields = ('sector', 'industry', 'marketplace')
search_fields = ('symbol',)
this way, when I query ...?search=AMZ it will only return records with a non-sensitive match in the symbol field.
If I add another element into the search_fields tuple, it will look for this same search string in both.
Is there a way to define these search fields individually that will allow me to do something like:
?search_symbol=AMZ&search_name=Good so that it looks for objects that have AMZ in symbol field and good in name field?