You can pass user as argument to method like this:
def user_vote(self, user):
also I guess you need to get a Vote instance, not queryset, so you should user .get
method instead .filter
:
def user_vote(self, user):
try:
data = Vote.objects.get(post=self, user=user)
return data.vote
except ObjectDoesNotExist:
#not voted
then you can call this method with Post instance:
post.user_vote(request.user)
UPDATE
Django not allow to use method with arguments in template. So in your case better to refactor this method into templatetag:
def get_user_vote(post, user):
try:
data = Vote.objects.get(post=post, user=user)
return data.vote
except ObjectDoesNotExist:
#not voted
You can find manual here https://stackoverflow.com/a/6493001/3291969
don't forget to register it :)