Add a "register" class decorator for admin.
|Reported by:||stavros||Owned by:||BHold|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The syntax for registering an admin class is a bit unpythonic, so I propose that the admin.site.register method should also have the capability of being used as a decorator.
A simple implementation is below:
def register_admin(model): def wrapper(klass): admin.site.register(model, klass) return klass return wrapper
I feel that
@register(MyModel) class AdminClass: pass
is more pythonic than
class AdminClass: pass register(MyModel, AdminClass)
which just screams "decorator".
Change History (12)
comment:1 Changed 3 years ago by julien
- Component changed from Uncategorized to contrib.admin
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:5 in reply to: ↑ 4 Changed 3 years ago by BHold
comment:8 follow-up: ↓ 9 Changed 3 years ago by stavros
comment:11 Changed 2 years ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from new to closed