Skip to content

Instantly share code, notes, and snippets.

@chriskief
Last active December 26, 2015 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriskief/7131821 to your computer and use it in GitHub Desktop.
Save chriskief/7131821 to your computer and use it in GitHub Desktop.
from django.views.generic import TemplateView
class Handler500(TemplateView):
template_name = '500.html'
@classmethod
def as_error_view(cls):
v = cls.as_view()
def view(request):
r = v(request)
r.render()
return r
return view
# must also override this method to ensure the 500 status code is set
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
return self.render_to_response(context, status=500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment