Skip to content

Instantly share code, notes, and snippets.



Last active Dec 26, 2015
What would you like to do?
from django.views.generic import TemplateView
class Handler500(TemplateView):
template_name = '500.html'
def as_error_view(cls):
v = cls.as_view()
def view(request):
r = v(request)
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