From b401bf0ef7b6945ffb07f905dd59e1868a48671c Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Fri, 1 Jan 2016 10:43:58 +0300 Subject: [PATCH] Fix bug with multiple paginations Since `parser.tokens` doesn't returns a whole tokens of a template, in this case the last remaining autopaginate tag makes `multiple_paginations` false, so page-suffix of the last paginate tag will be empty. --- linaro_django_pagination/templatetags/pagination_tags.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index da22e95..d07bc61 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -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 = '' -- 2.20.1