Skip to content

Commit

Permalink
Replace self.queryset with Viewset method equivalents (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
harikvpy authored Aug 18, 2022
1 parent 06893fb commit 89a6f59
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vote/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class VoteMixin:
def get_instance(self, pk):
return self.queryset.get(pk=pk)
return self.get_queryset().get(pk=pk)

@action(detail=True, methods=('post', 'delete'))
def vote(self, request, pk):
Expand All @@ -16,7 +16,7 @@ def vote(self, request, pk):
action = request.data.get('action', 'up')
voted = getattr(obj.votes, action)(user_id)
if voted:
post_voted.send(sender=self.queryset.model,
post_voted.send(sender=self.get_serializer_class().Meta.model,
obj=obj,
user_id=user_id,
action=action)
Expand All @@ -25,7 +25,7 @@ def vote(self, request, pk):
else:
deleted = obj.votes.delete(user_id)
if deleted:
post_voted.send(sender=self.queryset.model,
post_voted.send(sender=self.get_serializer_class().Meta.model,
obj=obj,
user_id=user_id,
action='delete')
Expand Down

0 comments on commit 89a6f59

Please sign in to comment.