Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions wkhtmltopdf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,20 +314,16 @@ def render_to_temporary_file(template, context, request=None, mode='w+b',
try:
render = template.render
except AttributeError:
content = loader.render_to_string(template, context)
content = loader.render_to_string(template, context, request=request)
else:
if django.VERSION < (1, 8):
# If using a version of Django prior to 1.8, ensure ``context`` is an
# instance of ``Context``
if not isinstance(context, Context):
if request:
context = RequestContext(request, context)
else:
context = Context(context)
# Handle error when ``request`` is None
content = render(context)
else:
content = render(context, request)
# Ensure ``context`` is an instance of ``Context``
if not isinstance(context, Context):
if request:
context = RequestContext(request, context)
else:
context = Context(context)
content = render(context)

content = smart_str(content)
content = make_absolute_paths(content)

Expand Down