dkoug Blog

Login protected CBV Django

Django -- Posted on July 17, 2017

Login protected CBV Django

1
2
3
4
5
6
7
8
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required

class ProtectedViewMixin(object):

    @method_decorator(login_required)
    def dispatch(self, *args, **kwargs):
        return super(ProtectedViewMixin, self).dispatch(*args, **kwargs)