Fixed a grave error wherein Node did not have a TreeManager as its default manager...
[philo.git] / contrib / penfield / utils.py
1 from django.core.paginator import Paginator, InvalidPage, EmptyPage
2
3
4 def paginate(request, entries, entries_per_page):
5         paginator = Paginator(entries, entries_per_page)
6         try:
7                 page_number = int(request.GET.get('page', '1'))
8                 entries = paginator.page(page_number).object_list
9                 page = paginator.page(page_number)
10         except ValueError:
11                 page_number = 1
12                 entries = paginator.page(page_number).object_list
13                 page = paginator.page(page_number)
14         try:
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)
20         return page