[EMAIL PROTECTED] написав(ла):
> > I have a Sale model that foreign keys into an APN model, which
> > foreign keys into a Zip model. I'd like to sort my Sale objects by
> > the 'zip' field on the Zip model, but
> >
> > Sale.objects.select_related().order_by('sales_zip.zip')
> >
> > doesn't work (1054, "Unknown column 'sales_zip.zip' in 'order
> > clause'"). It only works if I sort by something on the APN model,
> > which is one foreign-key hop instead of two.
> >
> > Is there an easy way to do this? Am I missing something? I'm running
> > 0.96 but not opposed to the trunk alternative.

You might take want to add an
    extra(table=['sales_zip'])
to your query.  The other table doesn't gets into the sql statement by
default.

This might be available only on trunk.

-- 
Sincerely,

Andrey Khavryuchenko            http://a.khavr.com/
KDS Software Group              http://www.kds.com.ua/
Software Solutions Company

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