aboutsummaryrefslogtreecommitdiffstats
path: root/wkhtmltopdf/views.py
diff options
context:
space:
mode:
authorCharlie Denton <charlie@meshy.co.uk>2014-06-19 11:46:18 +0100
committerCharlie Denton <charlie@meshy.co.uk>2014-06-19 11:46:18 +0100
commit8e615cf00343d61e2bf3716c66888758aeb878ed (patch)
tree9f6f4ada901749eaeddb32ac75c0955a5327c2b5 /wkhtmltopdf/views.py
parent0de693a16fa35525d3adb115bf8bf21c76581d0b (diff)
parent301bef0d6931582583a156b3195b8b13f54d2875 (diff)
downloaddjango-wkhtmltopdf-8e615cf00343d61e2bf3716c66888758aeb878ed.tar.gz
django-wkhtmltopdf-8e615cf00343d61e2bf3716c66888758aeb878ed.tar.bz2
django-wkhtmltopdf-8e615cf00343d61e2bf3716c66888758aeb878ed.zip
Merge pull request #48 from incuna/python3
Add Python3 support
Diffstat (limited to 'wkhtmltopdf/views.py')
-rw-r--r--wkhtmltopdf/views.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py
index 5a46490..2f1945d 100644
--- a/wkhtmltopdf/views.py
+++ b/wkhtmltopdf/views.py
@@ -77,12 +77,18 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse):
content = smart_str(template.render(context))
content = make_absolute_paths(content)
- tempfile = NamedTemporaryFile(mode=mode, bufsize=bufsize,
- suffix=suffix, prefix=prefix,
- dir=dir, delete=delete)
+ try:
+ # Python3 has 'buffering' arg instead of 'bufsize'
+ tempfile = NamedTemporaryFile(mode=mode, buffering=bufsize,
+ suffix=suffix, prefix=prefix,
+ dir=dir, delete=delete)
+ except TypeError:
+ tempfile = NamedTemporaryFile(mode=mode, bufsize=bufsize,
+ suffix=suffix, prefix=prefix,
+ dir=dir, delete=delete)
try:
- tempfile.write(content)
+ tempfile.write(content.encode('utf-8'))
tempfile.flush()
return tempfile
except: