1👍
✅
Just inherit from the View
model and override the view method.
class ICalDownload(View):
def get(self, *args, **kwargs):
# return your response just like you would in a function view.
If you want to protect the view, I like to use django-braces. Otherwise, you need to use method_decorator
on the dispatch method:
@method_decorator(auth_required)
def dispatch(self, *args, **kwargs):
return super(ICalDownload, self).dispatch(*args, **kwargs)
At this point, a function based view might be a little simpler, but like you, I like to always use class based views.
Source:stackexchange.com