From 10e742446d962889e821a31306fc0388961fccb2 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Sat, 29 Aug 2020 14:21:01 +0200 Subject: different response for pdf downloads --- client/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/views.py b/client/views.py index b1b8297..57747ee 100644 --- a/client/views.py +++ b/client/views.py @@ -49,9 +49,11 @@ def index(request): context = {'doc': document} html = template.render(context) pdf = pdfkit.from_string(html, False) - result = BytesIO(pdf) - result.seek(0) - return FileResponse(result, as_attachment=True, filename=document.document_type.name+".pdf") + # build response + filename = document.document_type.name + ".pdf" + response = HttpResponse(pdf, content_type='application/pdf') + response['Content-Disposition'] = 'attachment; filename="' + filename + '"' + return response elif request.POST["action"][0] == 'a': # sign autosign doc if document.status == "autosign": -- cgit v1.2.1