The Django documentation gives examples for using annotate() to produce aggregate results based on related fields of a QuerySet (i.e., using joins in annotate()).
A simplified example from the docs is for instance Store.objects.annotate(min_price=Min('books__price'))
, where books is a ManyToMany field of Store to Book and price is a field of Book.
To continue this example, how would I generate an annotated QuerySet of Store objects with the lowest prices not for all books in the store, but just for books with "author='William Shakespeare'"? In other words, how do I filter the related fields used to calculate the aggregate?