May 2018
Beginner to intermediate
282 pages
7h 58m
English
There are two ways to control access to a view:
@login_required(MyView.as_view())
from django.utils.decorators import method_decorator
class LoginRequiredMixin:
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
class LoginRequiredMixin:
def dispatch(self, request, *args, **kwargs):
if not request.user.is_authenticated():
raise PermissionDenied
return super().dispatch(request, *args, **kwargs)
When ...
Read now
Unlock full access