Allow explicit page suffix.
[django-pagination.git] / fnp_django_pagination / templatetags / pagination_tags.py
index c56f44d..3d6a973 100644 (file)
@@ -42,10 +42,8 @@ from django.template import (
     loader,
 )
 
-try:
-    from django.template.base import TOKEN_BLOCK
-except ImportError:     # Django < 1.8
-    from django.template import TOKEN_BLOCK
+from django.template.base import TokenType
+TOKEN_BLOCK = TokenType.BLOCK
 
 from django.template.loader import select_template
 from django.utils.text import unescape_string_literal
@@ -144,7 +142,9 @@ class AutoPaginateNode(Node):
         if self.multiple_paginations and 'multiple_paginations' not in context:
             context['multiple_paginations'] = True
 
-        if context.get('multiple_paginations') or getattr(context, "paginator", None):
+        if context.get('page_suffix'):
+            page_suffix = context['page_suffix']
+        elif context.get('multiple_paginations') or getattr(context, "paginator", None):
             page_suffix = '_%s' % self.queryset_var
         else:
             page_suffix = ''
@@ -195,8 +195,7 @@ class PaginateNode(Node):
         new_context = paginate(context)
         if self.template:
             template_list.insert(0, self.template)
-        with context.push(new_context):
-            return loader.render_to_string(template_list, context)
+        return loader.render_to_string(template_list, new_context)
 
 
 def do_paginate(parser, token):