3 # Django Default 403.html handler
4 # http://wtanaka.com/django/django403
6 # Copyright (C) 2009 Wesley Tanaka <http://wtanaka.com/>
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 import django
.template
23 import django
.template
.loader
25 def fallback_403(request
):
27 Fallback 403 handler which prints out a hard-coded string patterned
28 after the Apache default 403 page.
33 return django
.http
.HttpResponseForbidden(
34 _("""<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
36 <title>403 Forbidden</title>
39 <p>You don't have permission to access %(path)s on this server.</p>
41 </body></html>""") % {'path': request
.path
})
43 def access_denied(request
, template_name
='403.html'):
45 Default 403 handler, which looks for the which prints out a hard-coded string patterned
46 after the Apache default 403 page.
51 The django request object
53 t
= django
.template
.loader
.get_template(template_name
)
55 template_values
['request'] = request
56 return django
.http
.HttpResponseForbidden(
57 t
.render(django
.template
.RequestContext(request
, template_values
)))