try:
    vote = Vote.objects.get(answer=answer, user=request.user)
except Vote.DoesNotExist:
    pass
else:
    return HttpResponse("{'success': 'false'}")
if request.POST['type'] == 'up':
    answer.score = answer.score + 1
else:
    answer.score = answer.score - 1
answer.save()
How can you make a vote-up-down button like in Stackoverflow?