I got a query currently looking like this:
x = Model.objects.values("city").annotate(Sum("a")).annotate(Sum("b"))
city
is a choicefield, which means I need to do get_FOO_display()
on it, but I can't as values()
returns a non-query set of a list of tuples, so everything’s evaluated there already.
If I change values()
to filter()
or only()
it works, but assuming I got 2 db inputs, one adding 500 to a
and one adding 500 to b
, then it would create two rows in my table in the template, instead of summing both fields in same row.
How could I get the value
from my choicefield and sum both values in the same row?