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 15 months 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 14 months ago by BHold
comment:8 follow-up: ↓ 9 Changed 13 months ago by stavros
comment:11 Changed 6 months ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from new to closed