Very often overriding dispatch or as_view comes as an easy method for toubleshooting issues with class based views. Here is a snippet showing this.
from django.shortcuts import render
from django.views.generic import View
from django.http import HttpResponse
from django.utils.decorators import classonlymethod
class SimpleView(View):
def get(self, request):
print('### SimpleView/get : request path = %s' % request.path)
return HttpResponse(request.path)
@classonlymethod
def as_view(cls, **initkwargs):
print('### SimpleView as_view')
self = cls(**initkwargs)
view = super(SimpleView, cls).as_view(**initkwargs)
return view
def dispatch(self, request, *args, **kwargs):
print('### SimpleView / dispatch : %s' % request.method)
return super(SimpleView, self).dispatch(request, *args, **kwargs)