[Fixed]-How to pass django error status to ajax


No matter if you’re using a Response from Django Rest Framework or the normal Django HttpResponse you always need to pass the keyworded argument status in order to make the response actually have the correct status code thus invoking the correct handler in your front end code.

What your last example does is only passing a data or content argument which is making the response class default to a 200 status code.

return Response(your_data, status=404)

Leave a comment