X-Git-Url: https://git.mdrn.pl/django-pagination.git/blobdiff_plain/087d48eaa49896e1297b6e26b3e89bb9164040e8..965be4085fb0c68c6462f131b08170c6ffa4fb3f:/linaro_django_pagination/templatetags/pagination_tags.py diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index 2d15e72..b447625 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -40,6 +40,7 @@ from django.template import ( TOKEN_BLOCK, TemplateSyntaxError, Variable, + loader, ) from django.template.loader import select_template from django.utils.text import unescape_string_literal @@ -93,8 +94,8 @@ def do_autopaginate(parser, token): if queryset_var is None: raise TemplateSyntaxError( "Invalid syntax. Proper usage of this tag is: " - "{%% autopaginate QUERYSET [PAGINATE_BY] [ORPHANS]" - " [as CONTEXT_VAR_NAME] %%}") + "{% autopaginate QUERYSET [PAGINATE_BY] [ORPHANS]" + " [as CONTEXT_VAR_NAME] %}") return AutoPaginateNode(queryset_var, multiple_paginations, paginate_by, orphans, context_var) @@ -185,11 +186,9 @@ class PaginateNode(Node): to_return = paginate(context) if self.template: template_list.insert(0, self.template) - t = select_template(template_list) - if not t: - return None - context = Context(to_return) - return t.render(context) + return loader.render_to_string(template_list, to_return, + context_instance = context) + def do_paginate(parser, token): @@ -201,7 +200,7 @@ def do_paginate(parser, token): paginate [using "TEMPLATE"] Where TEMPLATE is a quoted template name. If missing the default template - is used (paginate/paginate.html). + is used (paginate/pagination.html). """ argv = token.split_contents() argc = len(argv)