I am trying to do this:
UserLog.objects.filter(user=user).filter(action=\'message\').filter(timestamp__lt=now)[0:5].update(read=True)
but I
I was getting the same error when attempting to limit the number of records returned by a queryset.
I found that if we're using one of Django's class-based generic views such as the ArchiveIndexView, we can use the paginate_by = attribute to limit the number of records.
For example (in views.py):
from django.views.generic import ArchiveIndexView
from .models import Entry
class HomeListView(ArchiveIndexView):
""" Blog Homepage """
model = Entry
date_field = 'pub_date'
template_name = 'appname/home.html'
queryset = Entry.objects.filter(
is_active=True).order_by('-pub_date', 'title')
paginate_by = 30