... ition header so that browsers # present the option to save the file. buffer . seek ( 0 ) return FileResponse ( buffer , as_attachment = True , filename = "hello.pdf" ) コードとコメントが自分自身の意味を説明しているはずですが、いくつかの点には言及しておくべ ... キュメントがHTMLファイルや一般的な application/octet-stream バイナリコンテンツではなく、PDFファイルであることを伝えます。 as_attachment=True が FileResponse に渡されると、適切な Content-Disposition ヘッダが設定され、ウェブブラウザはそのマシンでデフォルトが設 ... されていたとしても、そのドキュメントをどのように扱うかを確認するダイアログボックスをポップアップするようになります。もし as_attachment パラメータが省略された場合、ブラウザはPDFを扱うために設定されたプログラムやプラグインを使ってPDFを扱います。 任意の filena ... ... ition header so that browsers # present the option to save the file. buffer . seek ( 0 ) return FileResponse ( buffer , as_attachment = True , filename = "hello.pdf" ) コードとコメントが自分自身の意味を説明しているはずですが、いくつかの点には言及しておくべ ... キュメントがHTMLファイルや一般的な application/octet-stream バイナリコンテンツではなく、PDFファイルであることを伝えます。 as_attachment=True が FileResponse に渡されると、適切な Content-Disposition ヘッダが設定され、ウェブブラウザはそのマシンでデフォルトが設 ... されていたとしても、そのドキュメントをどのように扱うかを確認するダイアログボックスをポップアップするようになります。もし as_attachment パラメータが省略された場合、ブラウザはPDFを扱うために設定されたプログラムやプラグインを使ってPDFを扱います。 任意の filena ... ... des functions for conveniently sending email, as well as classes for building and sending more complex email messages with attachments and multiple content types. 注釈 django.core.mail で送信されるメールの文字セットは、 DEFAULT_CHARSET 設定の値にセットされ ... rough the send_mail() and related wrapper functions. If you wish to use advanced features, such as BCC'ed recipients, file attachments, or multi-part email, you'll need to create EmailMessage instances directly. 注釈 This is a design feature. send_mail() a ... sending the email. reply_to : メールを送信するときに "Reply-To" ヘッダ内で使われる、受信者のアドレスのリストまたはタプル。 attachments : A list of attachments to put on the message. Each can be an instance of MIMEPart or EmailAttachment , or a tuple with a ... ... des functions for conveniently sending email, as well as classes for building and sending more complex email messages with attachments and multiple content types. 注釈 django.core.mail で送信されるメールの文字セットは、 DEFAULT_CHARSET 設定の値にセットされ ... rough the send_mail() and related wrapper functions. If you wish to use advanced features, such as BCC'ed recipients, file attachments, or multi-part email, you'll need to create EmailMessage instances directly. 注釈 This is a design feature. send_mail() a ... sending the email. reply_to : メールを送信するときに "Reply-To" ヘッダ内で使われる、受信者のアドレスのリストまたはタプル。 attachments : A list of attachments to put on the message. Each can be an instance of MIMEPart or EmailAttachment , or a tuple with a ... ... ith the appropriate CSV header. response = HttpResponse ( content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) writer = csv . writer ( response ) writer . writerow ([ "First row" , "Foo" , "Bar" , " ... ) return StreamingHttpResponse ( stream_batched_rows (), content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) テンプレートシステムを使う ¶ もしくは、 Django のテンプレートシステム を使って CSV を生 ... ith the appropriate CSV header. response = HttpResponse ( content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) # The data is hardcoded here, but you could load it from a database or # some other sou ... ... ith the appropriate CSV header. response = HttpResponse ( content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) writer = csv . writer ( response ) writer . writerow ([ "First row" , "Foo" , "Bar" , " ... ) return StreamingHttpResponse ( stream_batched_rows (), content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) テンプレートシステムを使う ¶ もしくは、 Django のテンプレートシステム を使って CSV を生 ... ith the appropriate CSV header. response = HttpResponse ( content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) # The data is hardcoded here, but you could load it from a database or # some other sou ... ... ttpResponse ( ... my_data , ... headers = { ... "Content-Type" : "application/vnd.ms-excel" , ... "Content-Disposition" : 'attachment; filename="foo.xls"' , ... }, ... ) Content-Disposition ヘッダについては Django 固有のものはありませんが、その構文を忘れや ... 合は、ビュー自体で 切断を処理する 必要があるかもしれません。 FileResponse オブジェクト ¶ class FileResponse ( open_file , as_attachment = False , filename = '' , ** kwargs ) [ソース] ¶ FileResponse はバイナリファイルに最適化された StreamingHttpResponse のサブ ... I サーバーが提供していれば wsgi.file_wrapper を使用し、そうでない場合はファイルを小さなチャンクでストリーミングします。 as_attachment=True だと、 Content-Disposition ヘッダーが attachment に設定され、ブラウザにファイルをダウンロードするように要求します。そ ... ... ttpResponse ( ... my_data , ... headers = { ... "Content-Type" : "application/vnd.ms-excel" , ... "Content-Disposition" : 'attachment; filename="foo.xls"' , ... }, ... ) Content-Disposition ヘッダについては Django 固有のものはありませんが、その構文を忘れや ... 合は、ビュー自体で 切断を処理する 必要があるかもしれません。 FileResponse オブジェクト ¶ class FileResponse ( open_file , as_attachment = False , filename = '' , ** kwargs ) [ソース] ¶ FileResponse はバイナリファイルに最適化された StreamingHttpResponse のサブ ... I サーバーが提供していれば wsgi.file_wrapper を使用し、そうでない場合はファイルを小さなチャンクでストリーミングします。 as_attachment=True だと、 Content-Disposition ヘッダーが attachment に設定され、ブラウザにファイルをダウンロードするように要求します。そ ... ... ルトでは現在時刻になります。 次の形式で文字列を出力します: Wdy, DD Mon YYYY HH:MM:SS GMT 。 content_disposition_header ( as_attachment , filename ) [ソース] ¶ RFC 6266 に指定された filename から Content-Disposition HTTPヘッダー値を構築します。 as_attachment ... ... th_info() . Added the samesite argument to HttpResponse.set_cookie() to allow setting the SameSite cookie flag. The new as_attachment argument for FileResponse sets the Content-Disposition header to make the browser ask if the user wants to download the fi ... 2026年10月08日