Re: adding permission_required decorator for class based view

2022-02-10 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
> > 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 login_require

Re: adding permission_required decorator for class based view

2022-02-10 Thread Martin Milon
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 ref

Re: adding permission_required decorator for class based view

2022-02-09 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
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: @meth