aboutsummaryrefslogtreecommitdiffstats
path: root/wkhtmltopdf/views.py
diff options
context:
space:
mode:
authorGeorge Hickman <george@ghickman.co.uk>2012-05-21 15:56:21 +0100
committerGeorge Hickman <george@ghickman.co.uk>2012-05-21 17:39:52 +0100
commit2fc62e5be9f0f4394507505c92b5174532db5e10 (patch)
treee67cecff193bce7d1161ee5e52820626329d2844 /wkhtmltopdf/views.py
parenta9e1c24ea0f810863c4d611148c41a24afe4ec62 (diff)
downloaddjango-wkhtmltopdf-2fc62e5be9f0f4394507505c92b5174532db5e10.tar.gz
django-wkhtmltopdf-2fc62e5be9f0f4394507505c92b5174532db5e10.tar.bz2
django-wkhtmltopdf-2fc62e5be9f0f4394507505c92b5174532db5e10.zip
Pass around args and kwargs in PDFResponse
In case you want to pass more things up to HttpResponse. Can't pass filename down though.
Diffstat (limited to 'wkhtmltopdf/views.py')
-rw-r--r--wkhtmltopdf/views.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py
index 36efaf5..164f94f 100644
--- a/wkhtmltopdf/views.py
+++ b/wkhtmltopdf/views.py
@@ -11,10 +11,11 @@ from wkhtmltopdf.utils import template_to_temp_file, wkhtmltopdf
class PDFResponse(HttpResponse):
- def __init__(self, content, **kwargs):
- super(PDFResponse, self).__init__(content, 'application/pdf')
- if 'filename' in kwargs:
- header_content = 'attachment; filename={0}'.format(kwargs.get('filename'))
+ def __init__(self, content, *args, **kwargs):
+ filename = kwargs.pop('filename', None)
+ super(PDFResponse, self).__init__(content, 'application/pdf', *args, **kwargs)
+ if filename:
+ header_content = 'attachment; filename={0}'.format(filename)
self.__setitem__('Content-Disposition', header_content)
@@ -55,7 +56,7 @@ class PDFTemplateView(TemplateView):
output = wkhtmltopdf(page_path, **pdf_kwargs)
if self._tmp_files:
map(os.remove, self._tmp_files)
- return self.response(output, self.get_filename())
+ return self.response(output, filename=self.get_filename())
def get_filename(self):
return self.filename