0
我試圖在名爲blogpage的模板中使用兩個視圖列表(post_list和classification_list)。這是我已經做了解決問題,但它沒有工作:如何在一個模板中合併x視圖
class GenViewList(ListView):
model = Posting,Classification
template_name = 'Blog/blogpage.html'
def get_context_data(self, **kwargs):
context=super(BlogViewList,self).get_context_data(**kwargs)
context['latest_post_list']=Posting.objects.filter().order_by('-id')[:30]
context['classification_list']=Classification.objects.all().order_by('id')
return context
任何幫助將不勝感激!
非常感謝,它的工作 –