On Wed, 2007-11-14 at 00:00 +0000, Michael wrote:
> Thanks Malcolm, this helped me on one problem I had.  But, I've
> another similar problem but in my case, I've multiple foreign keys, so
> I'm not sure what to do about the database table name part.
> 
> My models:
> class Member(models.Model):
>   # first_name, last_name, etc.
>   class Meta:
>         ordering = ['first_name', 'last_name']
> 
> class Team(model.Model):
>   foreman = model.ForeignKey(Member)
>   operator = model.ForeignKey(Member)
>   # and more ForeignKey(Member) fields
>   class Meta:
>         ordering = ['foreman',]
> 
> 
> In the admin interface this orders the Teams by the first_name,
> last_name of the foreman, which is what I want.  But in my view, when
> I try to get a list of Teams using:
>  all_teams = Team.objects.all()
> 
> the result isn't sorted by the foreman's [first_name, last_name].  I
> don't know what it's sorted by, it's not id either.

Try inspecting the SQL that Django generates for this statement (if you
don't know how, see the FAQ, but db.connection.queries is the place to
look) to see what's being generated.

You may well be totally screwed here, in which case I'm not going to
worry about it too much, since this feature is effectively broken in
trunk. When it works, that's fine. But it's not robust and is very
unpredictable. That's why I've rewritten it in the branch. So if the SQL
generated is broken, I can't really offer much hope except to say "wait
a little longer" until we get the rewrite finished. I'm targetting end
of the month (Django sprint) for a rough completion date.

Malcolm

-- 
On the other hand, you have different fingers. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to