{{{#!python
@method_decorator(login_required, name='get')
@method_decorator(login_required, name='post')
class SimpleView(View):
...
}}}
Instead of this lets modify function to polymorpic style:
{{{#!python
@method_decorator(login_required, name=['get', 'post'])
class SimpledView(View):
...
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32399>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> Allowing `method_decorator` to handle multiple function names would avoid
> invoking it multiple times:
>
> {{{#!python
> @method_decorator(login_required, name='get')
> @method_decorator(login_required, name='post')
> class SimpleView(View):
> ...
> }}}
>
> Instead of this lets modify function to polymorpic style:
> {{{#!python
> @method_decorator(login_required, name=['get', 'post'])
> class SimpledView(View):
> ...
> }}}
New description:
Allowing `method_decorator` to handle multiple function names would avoid
invoking it multiple times:
{{{#!python
@method_decorator(login_required, name='get')
@method_decorator(login_required, name='post')
class SimpleView(View):
...
}}}
Instead of this lets modify function to polymorpic style:
{{{#!python
@method_decorator(login_required, name=['get', 'post'])
class SimpleView(View):
...
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32399#comment:1>
Comment (by Alexey Kotenko):
I created this ticket because I want to get confirmation from the
community and contributors that this change is possible. After
confirmation I am ready to send PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/32399#comment:2>
* status: new => closed
* resolution: => wontfix
Comment:
Thanks for this proposition, I'm not sure it is worth additional
complexity. `@method_decorator` already supports multiple decorators,
supporting multiple methods would require a signature change (so a
backward incompatible change with a deprecation of the current signature,
etc.) or maybe a new decorator e.g. `@methods_decorator` (probably
confusing). Nevertheless we could evaluate a patch if you want to prepare
a proof of concept.
--
Ticket URL: <https://code.djangoproject.com/ticket/32399#comment:3>