def pdf_download(request, filename):
    path = os.expanduser('~/files/pdf/')
wrapper = FileWrapper(file(filename, 'rb'))
response = HttpResponse(wrapper, content_type=mimetypes.guess_type(filename)[0]
    )
response['Content-Length'] = os.path.getsize(filename)
python - making file downloadable