|admin.site.register decorator||Matt||5/28/11 2:41 AM|
Recently, I had to make more than one admin class in admin.py file.
I have never had a situation like this before.
I keept my admin classes in separate files in admin module.
It came to me that after each class definition you have to make
- Where is the best place to put this call?
after a AdminClass definition?
Try it, it looks ugly
- At the end of file with other registers?
it is similar to signals connect and template_tag registering.
Therefore it should be similarly decorated by decorator.
what do you think?
This one is even more ugly than previous one!
How about changing:
model_method.allow_tags = True
model_method.short_description = _( 'Model Method' )
@options(allow_tags=True, short_description=_('Model Method'))
|Re: admin.site.register decorator||Russell Keith-Magee||5/28/11 8:47 PM|
On Saturday, May 28, 2011, Mateusz Harasymczuk <ma...@harasymczuk.pl> wrote:
Says you. Given that admin registration has always been like this,
> - At the end of file with other registers?
I think this misses several important points.
Firstly, class decorators are a relatively recent addition on Python.
Secondly, a class decorator must be used at the same time as the class
Thirdly, statement-based registration you can also include business
I'm more sympathetic to this idea. This seems like a case where
isn't an error, but
Is, because the decorator named short_descriptionnn doesn't exist.