我想要保存帶有動態數據的模板,當我請求時它應該呈現保存的頁面而不是再次查詢數據庫。我的應用程序在views.py下面是我的示例代碼。請幫忙。如何用django中的動態數據保存模板
def severity_wise(request):
sev_chart=[["Severity","No. of Bugs"]]
sev_list=["1","2","3","4","5","6"]
for i in sev_list:
sev=dev_report.objects.filter(Q(severity=i),Q(status='S')|Q(status='N')|Q(status='A')|Q(status='O')|Q(status='W')|Q(status='I')|Q(status='P')|Q(status='H'))
list=["S"+i,len(sev)]
sev_chart.append(list)
sev_table=sev_chart[1:]
return render(request, 'WASS/severity_wise.html',{'sc':sev_chart , 'sl':sev_table })
爲什麼你不緩存視圖? – e4c5