我有这个代码
class DownloadView(TemplateView):
template_name = 'pdfform/create_form2.html'
def serve_pdf(self, request):
#pdf_data = magically_create_pdf()
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename="http://localhost/static/pdfs/angular.pdf"'
return response
当我转到该页面时,我得到了下载对话框,但我无法下载文件。它说
http 403 forbidden
现在我可以直接访问该文件,但将http://localhost/static/pdfs/angular.pdf
其放在浏览器中
我很害怕 static/pdfs/angular.pdf
,但同样的错误