My url will be something like: ... /? Search = modal.
I want to replace the "modal" with empty "" to 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
https://stackoverflow.com/questions/66055811/django-rest-framework-does-not-filter-after-resetting-queryset February 05, 2021 at 08:18AM
没有评论:
发表评论