I have a query that looks like the following:
filter = Q(filter stuff)
q = MyModel.objects.filter(filter).order_by().values('c1',
'c2',
'c3').annotate(Sum('c2'), Sum('c3'))
Now when I do this, the output essentially has all the unique triples of c1, c2, and c3. Which I don't want. I want it find all the unique values of c1, and add up the corresponding values of c2 and c3.
I was able to fix this by changing the query to the following
q = MyModel.objects.filter(filter).order_by().values('c1',
).annotate(Sum('c2'), Sum('c3'))
Which is great and gives me the desired output...but what I don't understand is why...
Shouldn't values specify the columns that I want, not restrict the output to the unique pairings of those outputs? Any help would be appreciated