Created
October 28, 2015 13:42
-
-
Save jessamynsmith/2a92920f011c382370e0 to your computer and use it in GitHub Desktop.
Using Django aggregates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from codementor import models as codementor_models | |
from django.db.models import Sum | |
payments = codementor_models.Payment.objects.all().order_by('date') | |
payments.count() | |
payments[:5] | |
payment_values = payments.values_list('date').annotate(total_earnings=Sum('earnings')) | |
payment_values.count() | |
payment_values[:5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment