1👍
The documentation at DRF (Django Rest Framework) should help you with what you’re trying to do:
In essence you need to override the queryset method and look for query_params:
Below is an example from DRF’s documentation:
class PurchaseList(generics.ListAPIView):
serializer_class = PurchaseSerializer
def get_queryset(self):
"""
Optionally restricts the returned purchases to a given user,
by filtering against a `username` query parameter in the URL.
"""
queryset = Purchase.objects.all()
username = self.request.query_params.get('username', None)
if username is not None:
queryset = queryset.filter(purchaser__username=username)
return queryset
Source:stackexchange.com