[Solved]-Django handler500 as a Class Based View

2👍

I think its actually quite simple (in Django 1.7 with Python 3.4):

views.py

from django.http import HttpResponse
from django.views.generic.base import View

class Custom500View(View):
    def dispatch(self, request, *args, **kwargs):
        return HttpResponse('My custom django 500 page')

urls.py

from .views import Custom500View

handler500 = Custom500View.as_view()

0👍

I would rather just use stock 500 templates with static HTML in vanilla Django then do anything with code. This is one toggle I believe should not be touched.

Leave a comment