2017-10-01 2 views

Répondre

4

Utilisez F() et annotate():

from django.db.models import F 

# the sum of the three columns `first`, `second` and `third` will be 
# accessible as `.my_sum` 
results = my_model.objects.annotate(
         my_sum=F('first') + F('second') + F('third'), 
         )