I want to make a PDF file in my project directory to be downloable instead of opening in the browser when a user clicks the link.
I followed this question Generating file to download with Django
But I'm getting error:
Exception Type: SyntaxError
Exception Value: can't assign to literal (views.py, line 119)
Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module, line 35
I created a download link:
<a href="/files/pdf/resume.pdf" target="_blank" class="btn btn-success btn-download" id="download" >Download PDF</a>
urls.py:
url(r'^files/pdf/(?P<filename>\{w{40})/$', 'github.views.pdf_download'),
views.py:
def pdf_download(request, filename):
path = os.expanduser('~/files/pdf/')
f = open(path+filename, "r")
response = HttpResponse(FileWrapper(f), content_type='application/pdf')
response = ['Content-Disposition'] = 'attachment; filename=resume.pdf'
f.close()
return response
The Error Line is:
response = ['Content-Disposition'] = 'attachment; filename=resume.pdf'
How can I make it downloable?
Thanks!
UPDATE
It is working in Firefox but not in Chrome v21.0.