Skip to content

Instantly share code, notes, and snippets.

@jjangdm
Created February 24, 2013 15:40
Show Gist options
  • Save jjangdm/5024249 to your computer and use it in GitHub Desktop.
Save jjangdm/5024249 to your computer and use it in GitHub Desktop.
today = datetime.datetime.now()
categoryNumber_list = Category.objects.all().values_list("categoryNumber",flat=True)
category_list = Category.objects.all()
income_list = Income.objects.filter(date__year=today.year)
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(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(temp_money)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment