1 from django.core.paginator import Paginator, InvalidPage, EmptyPage
4 def paginate(request, entries, entries_per_page):
5 paginator = Paginator(entries, entries_per_page)
7 page_number = int(request.GET.get('page', '1'))
8 entries = paginator.page(page_number).object_list
9 page = paginator.page(page_number)
12 entries = paginator.page(page_number).object_list
13 page = paginator.page(page_number)
15 entries = paginator.page(page_number).object_list
16 page = paginator.page(page_number)
17 except (EmptyPage, InvalidPage):
18 entries = paginator.page(paginator.num_pages).object_list
19 page = paginator.page(page_number)