i have model with 3 decimal fields i would like sum 2 and multiply for other field but with aritmetic calculation
i have used this query
(1) total = Model.objects.annotate(all=Sum(F('fieldA') + F('fieldB') * F('fieldC')))
but this return queryset with all calculation i have 3 record in db
print total
and return this
<QuerySet [<Model: Model object>, <Model: Model object>, <Model: Model object>]>
then I do a forloop with for to do the sum
for x in total:
variable += x.all
it is possible to return the sum of the 3 registers with the annotate in a single line,
as (1)total queryset
How could I do that?
thank for yours helps