Opened 5 years ago
Closed 5 years ago
#32399 closed New feature (wontfix)
Allow method_decorator() to accept a list/tuple of method names.
| Reported by: | Alexey Kotenko | Owned by: | nobody |
|---|---|---|---|
| Component: | Utilities | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Allowing method_decorator to handle multiple function names would avoid invoking it multiple times:
@method_decorator(login_required, name='get') @method_decorator(login_required, name='post') class SimpleView(View): ...
Instead of this lets modify function to polymorpic style:
@method_decorator(login_required, name=['get', 'post']) class SimpleView(View): ...
Change History (3)
comment:1 by , 5 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 5 years ago
comment:3 by , 5 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| Summary: | Allow method_decorator to handle multiple functions → Allow method_decorator() to accept a list/tuple of method names. |
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.
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.