0
My url will be something like.../? search=modal.
I want to replace the "modal" with empty "" so that clean the filter and return all records.
Views.py
class AnexoExamesViewSet(viewsets.ModelViewSet):
search_fields = ['descr']
filter_backends = (filters.SearchFilter,)
queryset = AnexoExames.objects.all()
serializer_class = AnexoExamesSerializer
def get_queryset(self):
queryset = AnexoExames.objects.all()
search_descr = self.request.query_params.get('search',None)
print(search_descr)
if search_descr=='modal':
queryset = AnexoExames.objects.filter(descr='')
return queryset
This way it is returning zero results