middleware.exception.ExceptionMiddleware

class ExceptionMiddleware

New in Django 1.10.

Catches exceptions raised during the request/response cycle and returns the appropriate response.

  • Http404 is processed by handler404 (or a more friendly debug page if DEBUG=True).
  • PermissionDenied is processed by handler403.
  • MultiPartParserError is processed by handler400.
  • SuspiciousOperation is processed by handler400 (or a more friendly debug page if DEBUG=True).
  • Any other exception is processed by handler500 (or a more friendly debug page if DEBUG=True).

Django uses this middleware regardless of whether or not you include it in MIDDLEWARE, however, you may want to subclass if your own middleware needs to transform any of these exceptions into the appropriate responses. LocaleMiddleware does this, for example.

doc_Django
2016-10-09 18:39:06
Comments
Leave a Comment

Please login to continue.