I used DjangoFilterBackend with all fields:
class EntitiesViewSet(viewsets.ModelViewSet):
queryset = Entity.objects.all()
serializer_class = EntitiesSerializer
pagination_class = StandardResultsSetPagination
filter_backends = (DjangoFilterBackend,)
filter_fields = '__all__'
It worked perfectly for querying through the url of one or more fields with fixed or boolean values.
like this:
http://localhost:8000/api/persons/?news_by_email=True
http://localhost:8000/api/persons/?issuer=SSP-SC
But I need to also filter for fields with null value and it is not working.
I tried:
/persons/?parent=null
/persons/?parent=Null
/persons/?parent=NULL
/persons/?parent=
/persons/?parent__isnull
Any suggestions in this same simplified process?
Any suggestions that require an extension or new viewset?
You may also want to query the 'exact' value, besides isnull. In that case,
filter_fields = {'parent': ['exact', 'isnull']}
And you can make a query with '=True',
/persons/?parent__isnull=True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With