from __future__ import absolute_import

from django import template
from django.contrib.auth.models import AnonymousUser

from vote.models import UP

register = template.Library()


@register.simple_tag
def vote_exists(model, user=AnonymousUser(), action=UP):
    if user.is_anonymous():
        return False
    return model.votes.exists(user.pk, action=action)

from __future__ import absolute_import

from django import template
from django.contrib.auth.models import AnonymousUser
from django import get_version

from vote.models import UP

register = template.Library()


@register.simple_tag
def vote_exists(model, user=AnonymousUser(), action=UP):
    if get_version() >= '2.0':
        if user.is_anonymous:
            return False
    elif user.is_anonymous():
        return False
    return model.votes.exists(user.pk, action=action)

Fix vote_exists template tag for django 2.0