Note that you can give Paginator a list/tuple, a Django QuerySet,
or any other object with a count() or __len__() method. When
determining the number of objects contained in the passed object,
Paginator will first try calling count(), then fallback to using
len() if the passed object has no count() method. This allows
objects such as Django’s QuerySet to use a more efficient count()
method when available.

This limits the number of objects per page and adds a paginator and
page_obj to the context. To allow your users to navigate between pages,
add links to the next and previous page, in your template like this:

Here’s an example using Paginator in a view
function to paginate a queryset:

fromdjango.core.paginatorimportPaginatorfromdjango.shortcutsimportrenderfrommyapp.modelsimportContactdeflisting(request):contact_list=Contact.objects.all()paginator=Paginator(contact_list,25)# Show 25 contacts per page.page_number=request.GET.get('page')page_obj=paginator.get_page(page_number)returnrender(request,'list.html',{'page_obj':page_obj})

In the template list.html, you can include navigation between pages in
the same way as in the template for the ListView above.