fix EmptyPage bug

This commit is contained in:
Sanj 2012-05-26 03:02:30 +05:30
parent f53db828af
commit d0b66564d9
2 changed files with 6 additions and 2 deletions

View File

@ -2,7 +2,7 @@
import os import os
from os.path import join from os.path import join
DEBUG = False DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
JSON_DEBUG = DEBUG JSON_DEBUG = DEBUG
LOCAL_DEVELOPMENT = True LOCAL_DEVELOPMENT = True

View File

@ -216,8 +216,12 @@ def shipList(request):
# qset = qset.filter(country__icontains=country) # qset = qset.filter(country__icontains=country)
qset = qset.order_by(sort) qset = qset.order_by(sort)
paginator = Paginator(qset, page_size) paginator = Paginator(qset, page_size)
results = paginator.page(page)
no_of_results = qset.count() 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", { return render_to_response("shipList.html", {
'ships': results.object_list, 'ships': results.object_list,
'no_of_pages': paginator.num_pages, 'no_of_pages': paginator.num_pages,