Previous Page Next Page

Q&A

Q.We used the Blog.objects.all() function to create a QuerySet of all objects. Couldn't I just use the Blog.object QuerySet object?
A.No. objects QuerySet is a special-case QuerySet object that acts as a "root" object that cannot be evaluated.
Q.Is there any way to limit the size of a QuerySet?
A.Yes. Because the QuerySet is basically a Python array, you can use the Python array slicing syntax to limit the size of the QuerySet:
first10 = Blog.objects.all()[:10]
second10 = Blog.objects.all()[10:20]

Previous Page Next Page