1

我正在尝试使用这样的通用视图显示最新的 5 篇文章:

urlpatterns = patterns('',
  (r'^$', 'django.views.generic.date_based.archive_index', 
  {
      'queryset': Post.objects.all()[:5], 
      'date_field': 'created_on', 
      'template_name': 'index.html'}
  })

但是我得到

断言错误在 /

获取切片后无法过滤查询。

我能做些什么?

4

1 回答 1

2

num_latest: The number of latest objects to send to the template context. By default, it's 15.

于 2010-08-01T20:51:47.150 回答