This section covers middleware classes available with django-richtemplates.

HTTP 403 Middleware

Page does not exists (404 error code) has build in support in Django but if it comes to the 403 error code handler it has nothing to offer out-of-the -box. Well, in fact, it has, and it is crucial for this middleware’s implementation: django.http.HttpResponseForbidden. If this middleware is installed and instance of django.http.HttpResponseForbidden is returned (which is done if django.core.exceptions.PermissionDenied is risen, too) then 403.html template is returned.


In order to use Http403Middleware you have to add it to your MIDDLEWARE_CLASSES at settings module. Here is an example:




Remember that 403 error code should be returned if server disallow user from entering a page so it is needed that this middleware comes after AuthenticationMiddleware most probably - it of course is up to you.

Table Of Contents

Previous topic


Next topic


This Page