0
對於特定型號,我有多個ListViews
。我有一個頁面應該顯示每個ListView
的結果數量並鏈接到該ListView。Django:如果等於計數
如何計算該視圖中的項目數?
dashboard.html
{% if status == 'Open' %}
{{ jobs.count }}
{% endif %}
儀表板視圖:
Dashboard(ListView):
model = Job
開啓檢視:
class JobOpenList(ListView):
def get_queryset(self):
return Job.objects.filter(status='Open')
關閉查看:
class JobClosedList(ListView):
def get_queryset(self):
return Job.objects.filter(status='Closed')