How do I get more information about the errors in my Ajax requests?
When error occurs in Django during a normal HTTP request, Django shows a descriptive error page with exception details.
However, when error occurs during an AJAX request, I just know the HTTP error code and that's it. I'd like to know as much details as I learn from a Django error page.
Your web server's error log will contain additional information about any uncaught exceptions.
Handle errors within your ajax request and use responseText to get the response text and put it into an empty div that you have created for that.
For example:
$.ajax({
url:"{% yourView %}",
dataType: 'json',
success: function(jsonData){
alert("Hooray!");
},
error: function(jqXHR, textStatus, errorThrown){
$('.errors_div').html(jqXHR.responseText);
}
});
The django error page will be rendered into div class=errors_div
Use Firebug. In Console you'll see the AJAX request, just right click -> Copy Response Content and save that as an HTML file.
Why not access the url directly in your browser's address bar so you see a normal traceback?
Wrap it in another view to change the MIME type to text/html.
I also often have a view that wraps the JSON output in a html tag so the Django Debug Toolbar works correctly.