Re: Ordering results by m2m relations without multiply results

2008-09-27 Thread Alessandro
2008/9/27 Malcolm Tredinnick <[EMAIL PROTECTED]>: > You might want to prefer to do the ordering in Python or as a second > pass. Is it possible to order in python a queryset object? The generic view I use needs a queryset. If it's not possible I have to rewrite my generic object list to use a

Re: Ordering results by m2m relations without multiply results

2008-09-27 Thread Alessandro Ronchi
2008/9/27 Malcolm Tredinnick <[EMAIL PROTECTED]>: > Not really, except for writing a raw SQL query. The raw SQL for this > type of query is very complicated and it's such an edge case (it's > trying to do if-then logic in SQL when you write it out) and not always > even possible, so Django

Re: Ordering results by m2m relations without multiply results

2008-09-26 Thread Malcolm Tredinnick
On Fri, 2008-09-26 at 16:29 +0200, Alessandro wrote: > I have a model with a m2m field "provincia". > I want to order my objects in this way: > If the object has a provincia = 'AA' on m2m relation must be the > bottom of my list. > > I tried query = query.order_by('-provincia') and it works

Ordering results by m2m relations without multiply results

2008-09-26 Thread Alessandro
I have a model with a m2m field "provincia". I want to order my objects in this way: If the object has a provincia = 'AA' on m2m relation must be the bottom of my list. I tried query = query.order_by('-provincia') and it works correctly (because AA is the first of the values), but I duplicates