From d0b66564d9586fdfb6b59ba3d03ba29a02773123 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sat, 26 May 2012 03:02:30 +0530 Subject: [PATCH] fix EmptyPage bug --- manifests/settings.py | 2 +- manifests/ships/views.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/manifests/settings.py b/manifests/settings.py index e64c013..2fab57d 100644 --- a/manifests/settings.py +++ b/manifests/settings.py @@ -2,7 +2,7 @@ import os from os.path import join -DEBUG = False +DEBUG = True TEMPLATE_DEBUG = DEBUG JSON_DEBUG = DEBUG LOCAL_DEVELOPMENT = True diff --git a/manifests/ships/views.py b/manifests/ships/views.py index 1df9794..cefd324 100644 --- a/manifests/ships/views.py +++ b/manifests/ships/views.py @@ -216,8 +216,12 @@ def shipList(request): # qset = qset.filter(country__icontains=country) qset = qset.order_by(sort) paginator = Paginator(qset, page_size) - results = paginator.page(page) no_of_results = qset.count() + try: + results = paginator.page(page) + except (EmptyPage, InvalidPage): + results = paginator.page(paginator.num_pages) + return render_to_response("shipList.html", { 'ships': results.object_list, 'no_of_pages': paginator.num_pages,