On Nov 28, 1:50 pm, Peter Bengtsson <[EMAIL PROTECTED]> wrote:
> The trick is to use <QuerySet>.query.group_by.
> Here's an example that will work::
Thank you for taking the time to putting this example together!
You are hereby granted the title "django query ninja"!
What I was trying to do was perhaps less complex.
I haven't gotten around to trying to sort the editions by the average
rating yet.
( When I do, I'll use this solution!)
I just want to order a users bookcollection by his/hers *own* rating.
Looking at your example I realize that I can first get an ordered list
of the edition ids and their corresponding rating, and then fetch the
edition objects in that order afterwards.
But isn't there a way to get all in one query?
In my head the query would look something like this:
user.edition_set.all().order_by(user__edition__rating)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---