dabapps / django-readers

A lightweight function-oriented toolkit for better organisation of business logic and efficient selection and projection of data in Django projects.
https://www.django-readers.org
BSD 2-Clause "Simplified" License
186 stars 7 forks source link

Add `pairs.sum()` helper #54

Closed pmg103 closed 2 years ago

pmg103 commented 2 years ago

It'd be useful to have a shortcut for this:

        {'credit': (
            qs.annotate(creditpot_balance_sum=Sum('creditpot__balance')),
            producers.attr('creditpot_balance_sum')
        )},

Something like

        {'credit': pairs.sum('creditpot__balance')},

Similar to existing pairs.has and pairs.count