Force convert range to list for python3 compatible
[django-pagination.git] / linaro_django_pagination / templatetags / pagination_tags.py
index da22e95..d6e121e 100644 (file)
@@ -140,7 +140,11 @@ class AutoPaginateNode(Node):
         self.multiple_paginations = multiple_paginations
 
     def render(self, context):
-        if self.multiple_paginations or getattr(context, "paginator", None):
+        # Save multiple_paginations state in context
+        if self.multiple_paginations and 'multiple_paginations' not in context:
+            context['multiple_paginations'] = True
+
+        if context.get('multiple_paginations') or getattr(context, "paginator", None):
             page_suffix = '_%s' % self.queryset_var
         else:
             page_suffix = ''
@@ -264,7 +268,7 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN):
         paginator = context['paginator']
         page_obj = context['page_obj']
         page_suffix = context.get('page_suffix', '')
-        page_range = paginator.page_range
+        page_range = list(paginator.page_range)
         # Calculate the record range in the current page for display.
         records = {'first': 1 + (page_obj.number - 1) * paginator.per_page}
         records['last'] = records['first'] + paginator.per_page - 1