X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/abb8f8d1494156a87dff52f21253b160a9dcac72..f0e090cd2c52bed508487276816d6e7e5d922448:/utils.py?ds=sidebyside diff --git a/utils.py b/utils.py index 11f9848..6fc2cff 100644 --- a/utils.py +++ b/utils.py @@ -74,15 +74,15 @@ def paginate(objects, per_page=None, page_number=1): except (TypeError, ValueError): # Then either it wasn't set or it was set to an invalid value paginator = page = None - - # There also shouldn't be pagination if the list is too short. Try count() - # first - good chance it's a queryset, where count is more efficient. - try: - if objects.count() <= per_page: - paginator = page = None - except AttributeError: - if len(objects) <= per_page: - paginator = page = None + else: + # There also shouldn't be pagination if the list is too short. Try count() + # first - good chance it's a queryset, where count is more efficient. + try: + if objects.count() <= per_page: + paginator = page = None + except AttributeError: + if len(objects) <= per_page: + paginator = page = None try: return paginator, page, objects @@ -99,5 +99,7 @@ def paginate(objects, per_page=None, page_number=1): page = paginator.page(page_number) except EmptyPage: page = None + else: + objects = page.object_list return paginator, page, objects