My original question
(http://groups.google.com/group/django-users/browse_frm/thread/1581881fb9c1ddc1/#):

Here is a simplified version of what I am trying to do:

App X:
class A:
    shortname = meta.CharField(maxlength=6)

App Y:
class B:
    the_A = meta.ForeignKey(A)

Y.views:
blist = bs.get_list(order_by=['as.shortname'])

But Django is telling me that there is no table named 'as'.
Everything seems to be importing fine. Does anyone have any
hints?

I even used fully qualified table names
(eg bs.get_list(order_by=['x_as.shortname']) ).

The answer was:

blist = bs.get_list(order_by=['as.shortname'], select_related=True)

Looking at the generated SQL in db.queries, adding select_related makes
Django
bring in every field in every related table, thereby making any field
you wish available
for use by the ORDER BY clause. Not the most efficient query for my
purposes, but
it will do for now.

jtm


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to