Allow explicit page suffix.
[django-pagination.git] / fnp_django_pagination / templatetags / pagination_tags.py
index 3802a47..3d6a973 100644 (file)
@@ -42,15 +42,8 @@ from django.template import (
     loader,
 )
 
-try:
-    from django.template.base import TokenType
-    TOKEN_BLOCK = TokenType.BLOCK
-except ImportError:
-    try:
-        # Django 1.8-1.11
-        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
@@ -149,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 = ''