Re: Aggregating annotations

2013-07-23 Thread Debanshu Kundu
This bug has been solved here: https://code.djangoproject.com/ticket/20782 On Friday, July 19, 2013 11:49:52 AM UTC+5:30, Debanshu Kundu wrote: > > If I have a model *Book* defined as: > > class Book(models.Model): >name = models.CharField(max_length=300) >pages = models.IntegerField() >

Re: Aggregating annotations

2013-07-23 Thread Debanshu Kundu
This bug has been solved here: https://code.djangoproject.com/ticket/20782 On Friday, July 19, 2013 10:05:46 PM UTC+5:30, Debanshu Kundu wrote: > > Also interestingly, if I do: > > Book.objects.values('rating').aggregate(Max('rating')) > > It returns an empty dict without performing any DB query!

Re: Aggregating annotations

2013-07-19 Thread Debanshu Kundu
Also interestingly, if I do: Book.objects.values('rating').aggregate(Max('rating')) It returns an empty dict without performing any DB query!! On Friday, July 19, 2013 11:49:52 AM UTC+5:30, Debanshu Kundu wrote: > > If I have a model *Book* defined as: > > class Book(models.Model): >name =

Re: Aggregating annotations

2013-07-19 Thread Debanshu Kundu
EDIT: the query should be: Book.objects.values('rating').annotate(books_per_rating=Count('id')).aggregate(Max('books_per_rating')) *books_per_rating* should be quoted in *Max* call. On Friday, July 19, 2013 11:49:52 AM UTC+5:30, Debanshu Kundu wrote: > > If I have a model *Book* defined as: > >