Re: order_by in different tables

2006-06-04 Thread Malcolm Tredinnick
On Sun, 2006-06-04 at 12:29 +0200, Guillermo Fernandez Castellanos wrote: > Hi, > > First of all, thanks to both of you. > > Mmm... even if Olive's answer works, it's indeed, as he say, not very > pythonic nor very django-like. > > On the other hand, I would not be very concerned about the fact

Re: order_by in different tables

2006-06-04 Thread Derek Hoy
There is something you might use as a workaround, which is to use a property in the model. I had a template where I wanted to list all the names of members of a workgroup, sorted by last name. The template had this: {% for item in workgroup.list|dictsort:"user_last_name" %} And in the workgroup

Re: order_by in different tables

2006-06-04 Thread Guillermo Fernandez Castellanos
Hi, First of all, thanks to both of you. Mmm... even if Olive's answer works, it's indeed, as he say, not very pythonic nor very django-like. On the other hand, I would not be very concerned about the fact that the developper must know the underlying database tablenames, as this already happen

Re: order_by in different tables

2006-06-03 Thread Malcolm Tredinnick
Hi Guillermo, On Tue, 2006-05-30 at 18:42 +0200, Guillermo Fernandez Castellanos wrote: > Hi, > > I've been reading the documentation about order_by(). They say, amont > others, that: > """ > To order by a field in a different table, add the other table's name > and a dot, like so: > Entry.objec

Re: order_by in different tables

2006-05-30 Thread olive
None of the documented method works for me: The only way I found to make it works (affter having suffered a lot) is: MyRelatedModel.objects.all().extra( select={'my_field': 'SELECT my_field FROM myapplication_mymodel WHERE myapplication_mymodel.id = myapplication_myrelatedmodel.mymodel