Imagine you have the following view based on a class:
class PostListView(ListView):
model = Post
ProtectedPostListView = login_required(PostListView.as_view())
and your urls.py:
url(r'posts$', ProtectedPostListView)
If you use this approach, you lose the ability to subclass ProtectedPostListVieweg
class MyNewView(ProtectedPostListView):
, .as_view() , login_required , .
, , , .
class PostListView(ListView):
model = Post
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(PostListView, self).dispatch(*args, **kwargs)
class MyNewView(PostListView):