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.
精彩评论