>
> If the mixins are the way to go, it should be reflected in the doc more
> (especially in the introduction doc).
If you want to make a PR with concrete edits, sure. Yes the example walks
you through applying login_required as a decorator, but it does also say:
These examples use
The introduction doc to class based
view https://docs.djangoproject.com/en/4.0/topics/class-based-views/intro/
seems to prefer decorators, as it only illustrates the decorator side of
things with code blocks, and doesn't illustrate mixins at all.
If the mixins are the way to go, it should be
Additionally, it's always possible to apply decorators to CBV's like this:
class MyView(...):
...
my_view = some_decorator(MyView.as_view())
Then use my_view in your urls.py. This works because as_view() returns the
"real view" function.
...and you can use method_decorator like this:
Hi,For class based views there are mixins, LoginRequiredMixin,
PermissionRequiredMixin which give the same
Hi,
as of today, adding a permission_required and / or a login_required
decorator on a class based view is a bit ugly, as you have to decorate the
dispatch method, which you then have to write down in your class.
On top of that, you can't directly use the decorator itself, as you have to
wrap