From d4c2881356622fbe0653c1e5e183f2c0dba8e79b Mon Sep 17 00:00:00 2001 From: floguy Date: Sun, 13 Jul 2008 22:15:50 +0000 Subject: [PATCH] Fixed #1. Thanks, Martin Mahner and Jannis Leidel. git-svn-id: https://django-pagination.googlecode.com/svn/trunk@21 7f1efe38-554e-0410-b69d-834cb44da2d5 --- CONTRIBUTORS.txt | 4 +++- pagination/middleware.py | 2 +- pagination/templatetags/pagination_tags.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 53288df..ce3e326 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -1 +1,3 @@ -Eric Florenzano \ No newline at end of file +Eric Florenzano +Martin Mahner +James Tauber \ No newline at end of file diff --git a/pagination/middleware.py b/pagination/middleware.py index dd69377..b99a7e3 100644 --- a/pagination/middleware.py +++ b/pagination/middleware.py @@ -6,5 +6,5 @@ class PaginationMiddleware(object): def process_request(self, request): try: request.page = int(request['page']) - except KeyError: + except (KeyError, ValueError): request.page = 1 \ No newline at end of file diff --git a/pagination/templatetags/pagination_tags.py b/pagination/templatetags/pagination_tags.py index 66d8640..ab00df7 100644 --- a/pagination/templatetags/pagination_tags.py +++ b/pagination/templatetags/pagination_tags.py @@ -71,7 +71,9 @@ class AutoPaginateNode(template.Node): paginator = paginator_class(value, self.paginate_by) try: page_obj = paginator.page(context['request'].page) - except: + except InvalidPage: + context[key] = [] + context['invalid_page'] = True return u'' context[key] = page_obj.object_list context['paginator'] = paginator -- 2.45.2