【发布时间】:2013-09-15 12:42:39
【问题描述】:
作为一名 Django 初学者,我正在学习由 django docs 在https://docs.djangoproject.com/en/1.5/intro/tutorial04/提供的教程
在其中,他们展示了使用按发布日期进行查询列出的多个民意调查列表。我可以添加另一个列表,也可以在要使用的模板中使用。示例 在同一页面上按日期显示最新民意调查列表,并按字母顺序显示另一个。
class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_poll_list'
def get_queryset(self):
"""Return the last five published polls."""
return Poll.objects.order_by('-pub_date')[:5]
【问题讨论】:
标签: django django-views