On Mon, Jul 8, 2013 at 10:01 AM, Jorge C. Leitão
<
jorgeca...@gmail.com> wrote:
> Django allows users to define handlers to some exceptions, most notably
> http404, server error (status 500) and permission denied (status 403).
>
In fact, django already allows you to install handlers to process any
kind of unhandled exception, by installing middleware with a
process_exception() method that handles exceptions of that type.
> I here propose this feature to be extended to HttpResponseNotAllowed (status
> 405).
>
This is a HttpResponse subclass, not an exception. handle404 does not
get involved if you return a HttpResponseNotFound response from your
view, only if you raise a http.Http404 exception. Basically:
Middleware can handle any unhandled exception before the other
exception handlers are involved.
handle403 handles uncaught django.core.exceptions.PermissionDenied exceptions.
handle404 handles uncaught django.http.Http404 exceptions.
handle500 handles all other uncaught exceptions.
Cheers
Tom