0
ユーザーがリンク別にPDFファイルをダウンロードできるようにする機能。うまく動作します。唯一の問題は、ユーザーが保存するものが.htmlです。したがって、すべてのファイルはfile.pdf.htmlです。リンク別PDFファイルの提供、pdf.htmlとしてダウンロード
def download(request,ticket_id):
ticket_path = str(Ticket.objects.get(id=ticket_id).upload)
with open('files/media/' + ticket_path, 'rb') as pdf:
response = HttpResponse(pdf.read())
response['content_type'] = 'application/pdf'
response['Content-Disposition'] = 'attachment;filename="file.pdf"'
return response
なぜですか?
小さなタイプミスのattributeです。代わりにread()の準備ができました –
気づいてくれてありがとう、固定! –