[Fixed]-How to use Django ORM to function on a field

1👍

Not sure, but try F() expression

from datetime import timedelta

myModel.objects.annotate(
    count=Count("my_string"), 
    sum1=Sum('my_date'),
    sum2=Sum(F('my_date') + timedelta(days=1))
).values('my_string', 'count', 'sum1', 'sum2')

https://docs.djangoproject.com/en/dev/ref/models/queries/#f-expressions

Leave a comment