-
-
Save gregorynicholas/97fd96e2a679ff54ff539f094f81e32a to your computer and use it in GitHub Desktop.
Using Django aggregates
This file contains hidden or 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