From 063d36a38a18cba405dfaca99843b289f75d907d Mon Sep 17 00:00:00 2001 From: Max Peterson Date: Tue, 6 Sep 2011 12:02:51 +0100 Subject: Added smart_str --- wkhtmltopdf/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'wkhtmltopdf/utils.py') 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 -- cgit v1.2.3