1👍
You can define the lookup_field
attribute on the viewset so that it filters the Vote queryset by the player_id field.
class PlayerVotesViewSet(viewsets.ModelViewSet):
queryset = Vote.objects.all()
serializer_class = VoteSerializer
lookup_url_kwarg = 'player_id'
lookup_field = 'player_id'
Then in your router you should define the path as:
api_router.register(r'votes/players', PlayerVotesViewSet)
Source:stackexchange.com