>Personally I find the idea of "every model class has an objects
>property for manipulation in bulk, except when it doesn't" pretty
>horrifying, especially from a code maintenance point of view. I guess
>if people really want to make their lives more difficult we should
>let them but I certainly wouldn't want it suggested as Django best
>practise.

Actually I think the magic-removal way is quite good. It's some simple
steps where each step is bound to a specific need:

- by standard, the model class has an objects attribute that has a
default manager. This can be used to access data - and it's the most
simple case.

Now the specific need that's added is either one of those:

- you already have an attribute named "objects" - usually this will be
due to legacy database models
- you need more than one manager, with different behaviours
- you need just one manager, but it should behave differently from the
default (because you want to overload some of the bulk methods)

In any of those cases, you have to make managers explicit. So you
define a manager class and add it as an attribute to your model class.
I really don't see where this is "clumsy" :-)

One thing I would agree to is, the default 'objects' is magic that
should be removed. Actually that was my position in the discussion, to
make the manager assignment _allways_ explicit, so people allways will
choose the name of the manager object ;-)

bye, Georg

Reply via email to