1👍
✅
It seems that you’d like to just filter the queryset based on some given parameters. You should look at the django-filter and DRF filtering options. They might be what you really need. Filtering
…/blogs/?owner=1
This will give you all blogs that have “owner” field equal to user with id==1
Another option is to use @list_route decorator inside your viewset like this:
@list_route
def popular(self, request)
.... # Do stuff
return Response(data, status=status.HTTP_200_OK)
This will add a blogs route to your viewset and return whatever you tell it to return.
So going to ‘../blogs/popular/’ will return ‘data’
Source:stackexchange.com