TOKEN_BLOCK,
TemplateSyntaxError,
Variable,
+ loader,
)
from django.template.loader import select_template
from django.utils.text import unescape_string_literal
self.multiple_paginations = multiple_paginations
def render(self, context):
- if self.multiple_paginations or "paginator" in context:
+ if self.multiple_paginations or getattr(context, "paginator", None):
page_suffix = '_%s' % self.queryset_var
else:
page_suffix = ''
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):
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)