>>> p.residentialunitmix_set.all().query.as_sql()

(u'SELECT `tbl_ResidentialUnitMix`.`id`,
`tbl_ResidentialUnitMix`.`Planning-id`,
`tbl_ResidentialUnitMix`.`quantity`,
`tbl_ResidentialUnitMix`.`Bedrooms`, `tbl_ResidentialUnitMix`.`Type`,
`tbl_ResidentialUnitMix`.`Tenure` FROM `tbl_ResidentialUnitMix` WHERE
`tbl_ResidentialUnitMix`.`Planning-id` = %s '  , (82))

>>> p.residentialunitmix_set.select_related().query.as_sql()

(u'SELECT `tbl_ResidentialUnitMix`.`id`,
`tbl_ResidentialUnitMix`.`Planning-id`,
`tbl_ResidentialUnitMix`.`quantity`,
`tbl_ResidentialUnitMix`.`Bedrooms`, `tbl_ResidentialUnitMix`.`Type`,
`tbl_ResidentialUnitMix`.`Tenure` FROM `tbl_ResidentialUnitMix` WHERE
`tbl_ResidentialUnitMix`.`Planning-id` = %s '  , (82))

Tenure is a foreign key to another tables. How come both queries are
identical?

I am trying to sort by a field in the Tenure table and:
residentialunitmix_set.select_related().order_by('tbl_lkp_ResidentialUnitMix_Tenure.sort')

just gives an error. Looking at the queries explained why.

(Apologies for the table names. It's a Django interface to something
developed in Access)
--~--~---------~--~----~------------~-------~--~----~
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