Created
December 29, 2011 07:58
-
-
Save dfalk/1532789 to your computer and use it in GitHub Desktop.
django 404 context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File handlers.py | |
from django.shortcuts import render_to_response | |
from django.template import RequestContext, Context | |
from functools import partial | |
def base_error(request, template_name=None): | |
try: | |
context = RequestContext(request) | |
except: | |
context = Context() | |
return render_to_response(template_name, context_instance=context) | |
page_not_found = partial(base_error, template_name='404.html') | |
server_error = partial(base_error, template_name='500.html') | |
# Your root urls.py file should have this | |
handler404 = 'handlers.page_not_found' | |
handler500 = 'handlers.server_error' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment