#15607: Custom error templates in a single Django application
-----------------------------------------+----------------------
Reporter: jose | Owner: nobody
Status: closed | Milestone:
Component: HTTP handling | Version: 1.2
Resolution: needsinfo | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 |
-----------------------------------------+----------------------
Comment (by adrian):
So basically jose is saying you should be able to override the global
handler404 and handler500 within a "child" urls.py. I think this wouldn't
be worth adding, because it would be adding cruft to an already-crufty
API. (I'd like to make a cleaner way of doing handler404/handler500 down
the road -- it seems crufty as-is.)
jose: You can accomplish what you want by returning a custom HttpResponse
class from your view with {{{status_code}}} 404, like this:
{{{
response = render_to_response('custom_404_template.html', context)
response.status_code = 404
return response
}}}
If you don't want to do this from every view, you can write a middleware
that catches 404s and does different things depending on context/URL.
--
Ticket URL: <http://code.djangoproject.com/ticket/15607#comment:5>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.