文件入門禁止我有這樣的代碼同時下載在Django視圖
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
在瀏覽器的
我TREID puting static/pdfs/angular.pdf
但同樣的錯誤
我認爲這個頁面可能是有用的:http://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files –