[Django]-Django 1.7 and smart, deep, filtered aggregations

0👍

I don’t believe using prefetch gets you any gain in this situation. Generally prefetch_related and select_related are used when looping through a filterset and accessing a related object for each. By doing the annotate in the initial query I believe django will take of that optimization for you.

For the question “Get each user annotated with their “points” try this query:

Player.objects.annotate(total_right=models.Count('games__questions__right'))

Leave a comment