#5617: Default server_error view should render with RequestContext
-------------------------------------------------------------+--------------
Reporter: Nick Fishman <[EMAIL PROTECTED]> | Owner: nobody
Status: closed | Milestone:
Component: HTTP handling | Version:
SVN
Resolution: wontfix | Keywords:
server_error, RequestContext, error, templates
Stage: Unreviewed | Has_patch:
1
Needs_docs: 0 | Needs_tests:
0
Needs_better_patch: 0 |
-------------------------------------------------------------+--------------
Comment (by tobias):
what about something like this?
{{{
def render_safe(request, template_name):
t = loader.get_template(template_name)
try:
context = RequestContext(request, {'request_path':
request.path})
return t.render(context)
except:
return t.render(Context({}))
def page_not_found(request, template_name='404.html'):
"""
Default 404 handler.
Templates: `404.html`
Context:
request_path
The path of the requested URL (e.g.,
'/app/pages/bad_page/')
"""
return http.HttpResponseNotFound(render_safe(request,
template_name))
def server_error(request, template_name='500.html'):
"""
500 error handler.
Templates: `500.html`
Context: None
"""
return http.HttpResponseServerError(render_safe(request,
template_name))
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/5617#comment:3>
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
-~----------~----~----~----~------~----~------~--~---