Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More


This middleware is automatically being installed on every Lino site.

When an exception occurs during an AJAX call, Lino should not respond with Django’s default HTML formatted error report but with a plain-text traceback because that’s more readable when seen in a browser console.

Originally inspired by http://djangosnippets.org/snippets/650

Additions by LS:

  • also logs a warning on the development server because that is easier to read than opening firebug and look at the response.

  • must work also when DEBUG is False. Yes, on a production server it is not wise to publish the traceback, but our nice HTML formatted “Congratulations, you found a problem” page is never the right answer to an AJAX call.

  • format_request() adds information about the incoming call, including POST or PUT data.



The middleware class definition.

class lino.utils.ajax.AjaxExceptionResponse(get_response)

Bases: MiddlewareMixin

The middleware class definition.