Re: order_by result of sum of fields computed from an annotate

2013-11-19 Thread Leonardo Giordani
Well, indeed the matter is not simple =) I looked at the raw SQL for your queries and the results are the following (just print queryset.query to show SQL). The SQL query for Author.objects.extra(select={'average_delay': "Avg('all_books__published_date')-Avg('all_books__added_date')"}) is SELE

Re: order_by result of sum of fields computed from an annotate

2013-11-19 Thread Jorge Cardoso Leitão
I'm sorry, you are right, I should have provided them. Let me formulate the question again, but with a complete example. # models.py class Book(models.Model): added_date = models.DateField()# date it was added to my shelf published_date = models.DateField() # date it was publishe

Re: order_by result of sum of fields computed from an annotate

2013-11-18 Thread Leonardo Giordani
May you please post the code of Book and Author models? Thanks Leonardo Giordani Author of The Digital Cat My profile on About.me - My GitHub page- My Coderwall profile