0

Simple question I am trying to get the result of an aggregate to use in my view to make a simple calculation.

I have written the following.

sms_raised = SmsBacker.objects.values('amount').annotate(Sum('amount'))
sms_raised
[{'amount': 150L, 'amount__sum': 600}]

How do I access those values in the shell.

I have tried

sms_raised_amount
sms_raised__amount
sms_raised.amount

All with no luck

ApPeL
  • 4,801
  • 9
  • 47
  • 84

1 Answers1

3

Dict is the first item in the list, so

sms_raised[0]['amount']
sms_raised[0]['amount__sum']
DrTyrsa
  • 31,014
  • 7
  • 86
  • 86