Created
July 13, 2014 19:19
-
-
Save aaronlelevier/c63613db1ec38a828c3e to your computer and use it in GitHub Desktop.
Handle 404 and 500 errors easy with this snippet in your main Django views.py file. No urls.py configuration needed.
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
from django.shortcuts import render_to_response | |
from django.template import RequestContext | |
def handler404(request): | |
response = render_to_response('404.html', {}, | |
context_instance=RequestContext(request)) | |
response.status_code = 404 | |
return response | |
def handler500(request): | |
response = render_to_response('500.html', {}, | |
context_instance=RequestContext(request)) | |
response.status_code = 500 | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment