select_related after prefetch_related
问题 My Models looks like: class Book(models.Model): publisher = models.ForeignKey(Publisher) # This is not important class Baz(models.Model): a = models.CharField(max_length=100) class Page(models.Model): book = models.ForeignKey(Book) baz = models.ForeignKey(Baz) And I am trying to run a query like this: [[x.baz.a for x in y.page_set.all()] for y in Book.objects.all().prefetch_related('page_set', 'page_set__baz')] Which I think the ORM should be able to perform as two queries: ( Page JOIN Baz )