Skip to content

Instantly share code, notes, and snippets.

@jjangdm
Created February 1, 2013 07:49
Show Gist options
  • Save jjangdm/4689995 to your computer and use it in GitHub Desktop.
Save jjangdm/4689995 to your computer and use it in GitHub Desktop.
def report_total(request):
today = datetime.datetime.now()
categoryNumber_list = Category.objects.all().values_list("categoryNumber",flat=True)
category_list = Category.objects.all().values_list("item",flat=True)
monthly_list = []
for i in categoryNumber_list:
if int(i)<100:
for j in range(1,13):
temp_money = sum(Income.objects.filter(category__categoryNumber="%s" %i, date__year=today.year, date__month="%s" %j).values_list("money",flat=True))
monthly_list.append((int(i),temp_money),)
else:
for j in range(1,13):
temp_money = sum(Outcome.objects.filter(category__categoryNumber="%s" %i, date__year=today.year, date__month="%s" %j).values_list("money",flat=True))
monthly_list.append((int(i),temp_money),)
return render_to_response("./report/total.html", dict(today=today, .....))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment