开发者

How to get first top five objects with django.views.generic.date_based.archive_index?

I'm trying to display the latest 5 posts using a generic view like this:

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

However I am getting

Asser开发者_Python百科tionError at /

Cannot filter a query once a slice has been taken.

What can I do?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜