aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Peterson <max@incuna.com>2011-09-06 12:02:51 +0100
committerMax Peterson <max@incuna.com>2011-09-06 12:02:51 +0100
commit063d36a38a18cba405dfaca99843b289f75d907d (patch)
tree1fd8ff706502bc50209000b400a2c20906d41aba
parent725867ec68d7551569c396e913f82eb9504e9dc1 (diff)
downloaddjango-wkhtmltopdf-063d36a38a18cba405dfaca99843b289f75d907d.tar.gz
django-wkhtmltopdf-063d36a38a18cba405dfaca99843b289f75d907d.tar.bz2
django-wkhtmltopdf-063d36a38a18cba405dfaca99843b289f75d907d.zip
Added smart_str
-rw-r--r--wkhtmltopdf/utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py
index 8eb569b..17829fc 100644
--- a/wkhtmltopdf/utils.py
+++ b/wkhtmltopdf/utils.py
@@ -5,6 +5,7 @@ from tempfile import mkstemp
from django.conf import settings
from django.http import HttpResponse
from django.template import loader
+from django.utils.encoding import smart_str
WKHTMLTOPDF_CMD = getattr(settings, 'WKHTMLTOPDF_CMD', 'wkhtmltopdf')
@@ -82,12 +83,13 @@ def render_to_pdf(template_name, dictionary=None, context_instance=None, header_
response['Content-Disposition'] = 'attachment;' + ' filename=%s' %filename
return response
+import codecs
def template_to_temp_file(*args, **kwargs):
"""Renders a template to a temp file, and returns the path of the file."""
fd, tmppath = mkstemp(suffix='.html')
f = fdopen(fd, 'wt')
- f.write(loader.render_to_string(*args, **kwargs))
+ f.write(smart_str(loader.render_to_string(*args, **kwargs)))
f.close()
return tmppath