#19414: Add a "register" class decorator for admin.
-------------------------------+--------------------
Reporter: stavros | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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".
--
Ticket URL: <https://code.djangoproject.com/ticket/19414>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.