質問編集履歴
1
失礼しました。month_list=[]という記述と、month_list.append(month_sales)という記述を追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,8 +10,13 @@
|
|
10
10
|
customers = Custmer.objects.all()
|
11
11
|
for customer in customers:
|
12
12
|
sales = Sales.objects.filter(customer=customer) # 得意先別売上高をピックアップ
|
13
|
+
month_sales_list = [] # 各月の売上を入れるための空のリスト
|
13
14
|
for month in month_list:
|
14
15
|
month_sales = sales.filter(date__range=(month.start_date, month.end_date)) # 月別売上高をピックアップ
|
16
|
+
month_sales_list.append(month_sales) # 2018.1月売上、2018.2月売上、…
|
17
|
+
|
18
|
+
# ここで、customerにmonth_listというアトリビュートを持たせることができれば解決するのではないかと思います。
|
19
|
+
|
15
20
|
template = loader.get_template('test/sales.html')
|
16
21
|
context = {
|
17
22
|
'month_list': month_list,
|