Skip to content

Instantly share code, notes, and snippets.

@dittos
Forked from jjangdm/replace.py
Created December 4, 2012 11:08
Show Gist options
  • Save dittos/4202737 to your computer and use it in GitHub Desktop.
Save dittos/4202737 to your computer and use it in GitHub Desktop.
please
def report(request):
today = datetime.datetime.now()
executor = Executor.objects.all()
queryset = Budget.objects.filter(year=today.year)
aggregates = {}
for i in xrange(1, 25+1):
aggregates['out%d' % i] = models.Sum('out%d' % i)
budget = queryset.aggregate(**aggregates)
budget['sum_of_management_budget'] = budget['out1'] + budget['out2'] + budget['out3'] + budget['out4']
...
return render_to_response('report.html', budget)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment