views:

20

answers:

1

Hello,
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

AssertionError at /

Cannot filter a query once a slice has been taken.

What can I do?

+2  A: 

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

gruszczy