Is it possible to calculate the cumulative (running) sum using django\'s orm? Consider the following model:
class AModel(models.Model): a_number = models
You can try to do this with Func expression.
from django.db.models import Func, Sum AModel.objects.annotate(cumsum=Func(Sum('a_number'), template='%(expressions)s OVER (PARTITION BY %(partition_by)s)', partition_by='id')).values('id', 'cumsum').order_by('id')