I am trying to submit a login form using ajax. I am confused as to how I am supposed to handle the exceptions/successful responses. I am getting a 200 OK from the server and the
return HttpResponseRedirect(request.REQUEST.get('next', '/'))
You obviously cant use that if you are doing ajax , the client must be responsible of the redirection/display/whatever is sent back in the Ajax response. If the login is successful , send a JSON response telling the client to redirect itself( with javascript redirection ) , if it is not , send a JSON response with the list of errors and display them using javascript.