multiple annotate Sum terms yields inflated answer
In the following setup, I'd like a QuerySet with a list of projects, each annotated with the sum of all its task durations (as tasks_duration) and the sum of all of its tasks' subtask durations (as subtasks_duration). My models (simplified) look like this: class Project(models.Model): pass class Task(models.Model): project = models.ForeignKey(Project) duration = models.IntegerField(blank=True, null=True) class SubTask(models.Model): task = models.ForeignKey(Task) duration = models.IntegerField(blank=True, null=True) I make my QuerySet like this: Projects.objects.annotate(tasks_duration=Sum(