On 15 Sep 2010, at 14:28, Rev. Johnny Healey wrote:
> According to the django docs: "If you use custom Manager objects, take
> note that the first Manager Django encounters (in the order in which
> they're defined in the model) has a special status. Django interprets
> the first Manager defined in a class as the "default" Manager, and
> several parts of Django (including dumpdata) will use that Manager
> exclusively for that model."
>
> I may be missing something here, but this jumps out at me as being
> impossible. The ModelBase metaclass receive the attributes as a dict,
> so isn't the original order lost?
Good question. You're right the dict has no ordering.
If you look in django.db.models.manger though you'll see the definition of the
Manager class:
class Manager(object):
# Tracks each time a Manager instance is created. Used to retain order.
creation_counter = 0
...
i.e. each manager stores it's own "index" and it's that which is used to
determine order.
This trick is used a lot in Django.
http://docs.python.org/reference/datamodel.html#implementing-descriptors
Regards,
Carlton
--
You received this message because you are subscribed to the Google Groups
"Django users" 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 this group at
http://groups.google.com/group/django-users?hl=en.