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
example..."

e.g.::

Store.objects.filter(books__pubdate__year=2014).annotate(min_2014_price=Min('books__price'),
max_2014_price=Max('books__price'))


That's a very good info, many thanks for pointing me there!

Initially I thought that this would only limit/filter the Store objects that are annotated ("a filter has the effect of constraining the objects for which an annotation is calculated"), but the subsequent section https://docs.djangoproject.com/en/1.8/topics/db/aggregation/#order-of-annotate-and-filter-clauses clearly (in hindsight) explains that it, in this order, effectively filters the book objects that are used for the annotation as well.

Now if only I knew how to obtain the actual book objects related to the min/max prices...

Many thanks and best regards,
Carsten

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/55315B9C.8010702%40cafu.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to