From: Albert Tugushev Date: Fri, 1 Jan 2016 07:43:58 +0000 (+0300) Subject: Fix bug with multiple paginations X-Git-Tag: 2.2.0~2^2~3 X-Git-Url: https://git.mdrn.pl/django-pagination.git/commitdiff_plain/b401bf0ef7b6945ffb07f905dd59e1868a48671c?ds=sidebyside 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. --- 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 = ''