This Django app allows you to specify a default 403 Forbidden page simply by creating a 403.html template file. This file will get rendered every time a view in your Django application returns a vanilla, empty HttpResponseForbidden response object.
Download
You can download it on either GitHub or Gitorious.
Install
- download the files into a directory called
django403 - Add
'django403.middleware.Django403Middleware'toMIDDLEWARE_CLASSESin yoursettings.pyfile - Create a
403.htmltemplate file.
Usage
To trigger the template in your own views, simply use the statement:
return django.http.HttpResponseForbidden()
If you do not create a 403.html template file, or the app is not able to find your 403.html, then a plain hard-coded error page modeled after the Apache default 403 page will be displayed.
Caveat
I have only tested this using Google App Engine Helper for Django and the stock Google App Engine Django 0.96. Patches to fix problems in other environments/Django versions are greatly appreciated.
Feedback / Bug reports
Please give your feedback, report bugs or contribute patches on the Github project page.
