> #    app_list =
> camp.application_set.filter(year=year_filter).order_by('camps_application__c
> adet.sqn.wing.name')
> 
> You can see where I've commented-out what I wanted to do. The commented-out
> version gives :
> Exception Type:       OperationalError
> Exception Value:      (1054, "Unknown column
> 'camps_application__cadet.sqn.wing.name' in 'order clause'")

You have an addiction to dots...if you were doing unit tests, 
this would be A Good Thing(tm) :)  However, in an ORDER BY 
clause, not so much.

IIUC, you need to do a select_related() to attach the various 
tables to the query, and then you need to refer to the actual 
table that contains the "name" on which you sort.  This would 
most likely be something like

        camp.application_set.select_related().filter(
                year=year_filter).order_by('camps_wing.name')

where "camps_wing" is the name of the table that contains the 
"name" field on which you want to sort.  Or, perhaps it would be

        "camps_application__cadet__sqn__wing.name"

or some such combo.  The SQL that Django dumps in the 404 should 
be enough to figure out the alias for the table that's used.

AFAIK, a SQL "ORDER BY" clause expects "tablename.fieldname" (NB: 
/only/ one period)

-tkc





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