add request back from context and fix error handling
[django-pagination.git] / pagination / templatetags / pagination_tags.py
index fa8fd48..dd338a2 100644 (file)
@@ -104,7 +104,8 @@ class AutoPaginateNode(template.Node):
         context['page_obj'] = page_obj
         return u''
 
-def paginate(context, window=DEFAULT_WINDOW, hashtag=None):
+
+def paginate(context, window=DEFAULT_WINDOW, hashtag=''):
     """
     Renders the ``pagination/pagination.html`` template, resulting in a
     Digg-like display of the available pages, given the current page.  If there
@@ -213,6 +214,7 @@ def paginate(context, window=DEFAULT_WINDOW, hashtag=None):
             'is_paginated': paginator.count > paginator.per_page,
         }
         if 'request' in context:
+            to_return['request'] = context['request']
             getvars = context['request'].GET.copy()
             if 'page' in getvars:
                 del getvars['page']
@@ -221,7 +223,7 @@ def paginate(context, window=DEFAULT_WINDOW, hashtag=None):
             else:
                 to_return['getvars'] = ''
         return to_return
-    except KeyError, AttributeError:
+    except (KeyError, AttributeError):
         return {}
 
 register.inclusion_tag('pagination/pagination.html', takes_context=True)(