Re: annotate() questions

2015-04-24 Thread Carsten Fuchs
Am 17.04.2015 um 21:14 schrieb Carsten Fuchs: Now if only I knew how to obtain the actual book objects related to the min/max prices... Just for future reference, the best answer that I've found so far is: http://blog.roseman.org.uk/2010/08/14/getting-related-item-aggregate/ Best regards, Car

Re: annotate() questions

2015-04-17 Thread Carsten Fuchs
Hi Ramiro, Am 2015-04-16 um 19:30 schrieb Ramiro Morales: https://docs.djangoproject.com/en/1.8/topics/db/aggregation/#aggregations-and-other-queryset-clauses "...When used with an annotate() clause, a filter has the effect of constraining the objects for which an annotation is calculated. For

Re: annotate() questions

2015-04-16 Thread Ramiro Morales
On Wed, Apr 8, 2015 at 3:07 PM, Carsten Fuchs wrote: > Dear Django fellows, > > at https://docs.djangoproject.com/en/1.8/topics/db/aggregation/#joins-and- > aggregates the first example is: > > >>> from django.db.models import Max, Min > >>> Store.objects.annotate(min_price=Min('books__price'), >

Re: annotate() questions

2015-04-16 Thread Carsten Fuchs
Hello, Am 08.04.2015 um 20:07 schrieb Carsten Fuchs: 1) Is there a way to annotate each Store object with the actual Book objects related to the minimum and maximum prices? 2) Can this annotation be filtered? For example, if for each Store we wanted to learn the min and max prices of bo

annotate() questions

2015-04-08 Thread Carsten Fuchs
Dear Django fellows, at https://docs.djangoproject.com/en/1.8/topics/db/aggregation/#joins-and-aggregates the first example is: >>> from django.db.models import Max, Min >>> Store.objects.annotate(min_price=Min('books__price'), max_price=Max('books__price')) which will annotate each Store ob