views:

114

answers:

1

I'm using Django and django-voting in an app I'm making. If a user who is not authenticated tries to vote, an alert box is displayed telling them they are not authenicated. How can I catch this error and make it into a more elegant AJAX display so I can show it right on the page when it happens?

+1  A: 

just return JSON from your view with error. How to change django default errors markup to json its an interesting question. You can write custom method and add it to error class.

def as_json(errors):
    return dict((k, map(unicode, v)) for k, v in errors.items())