It isn't clear to me at all why this is the behaviour your would expect. No other Python object has an automatic and implied ordering on an arbitrary attribute, and there's nothing on the User model to say that "username" is the best attribute for this ordering (and I presume you meant "username", not "user"). The default User model doesn't have any predefined ordering defined. The order returned by the database is unpredictable (although, for small data sets, it will generally match the order of database insertion).
In theory, I suppose it would be possible for any object with an ordering defined to automatically gain a __cmp__
method that implements that search order. However, I'm not sure I agree that this sort of implicit behaviour would be desirable. It would also be complicated to implement in a way that doesn't override manually defined __cmp__
methods on a model.
It would also be possible to make a special case of the User object and manually define a __cmp__
method specifically for User; however, that would also act as an encouragement for people to do sorting in Django, rather than in the database (where the operation can be optimised).
So - marking this wontfix. If you want to argue for this change, please start a thread on django-developers.