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 = m

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 empt

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: > > cla

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: > >

Aggregating annotations

2013-07-19 Thread Debanshu Kundu
If I have a model *Book* defined as: class Book(models.Model): name = models.CharField(max_length=300) pages = models.IntegerField() price = models.DecimalField(max_digits=10, decimal_places=2) rating = models.FloatField() pubdate = models.DateField() and I run the query: Book.obj