... esponse object with 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" , "F ... 解釈し、ブラウザウィンドウに醜くて恐ろしいぐちゃぐちゃの文字列が現れてしまう恐れがあります。 レスポンスには、追加の Content-Disposition ヘッダに CSV のファイル名を設定することができます。ファイル名はどんなものでも構いません。ここで指定した名前は、ブラウザが「 ... for row in batch ) return StreamingHttpResponse ( stream_batched_rows (), content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) テンプレートシステムを使う もしくは、 Django のテンプレートシステム を使 ... ... erable to a reflected file download (RFD) attack that sets the Content-Disposition header of a FileResponse when the filename was derived from user-supplied input. The filename is now escaped to avoid this ... ... ble to a reflected file download (RFD) attack that sets the Content-Disposition header of a FileResponse when the filename was derived from user-supplied input. The filename is now escaped to avoid this ... ... ello world." ) # Close the PDF object cleanly, and we're done. p . showPage () p . save () # FileResponse sets the Content-Disposition header so that browsers # present the option to save the file. buffer . seek ( 0 ) return FileResponse ( buffer , as_attac ... イナリコンテンツではなく、PDFファイルであることを伝えます。 as_attachment=True が FileResponse に渡されると、適切な Content-Disposition ヘッダが設定され、ウェブブラウザはそのマシンでデフォルトが設定されていたとしても、そのドキュメントをどのように扱うかを確認 ... ... うようにブラウザに指示します。 ブラウザにレスポンスをファイル添付として扱うように指示するためには、 Content-Type と Content-Disposition ヘッダを設定します。例えば、Microsoft Excel スプレッドシートを返す方法は以下のようになります: >>> response = HttpResponse ... ( ... my_data , ... headers = { ... "Content-Type" : "application/vnd.ms-excel" , ... "Content-Disposition" : 'attachment; filename="foo.xls"' , ... }, ... ) Content-Disposition ヘッダについては Django 固有のものはありませんが、そ ... .file_wrapper を使用し、そうでない場合はファイルを小さなチャンクでストリーミングします。 as_attachment=True だと、 Content-Disposition ヘッダーが attachment に設定され、ブラウザにファイルをダウンロードするように要求します。それ以外の場合は、ファイル名が利用 ... ... rom the response. In addition, modifications to the Cache-Control header for all Internet Explorer requests with a Content-Disposition header have also been removed as they were found to have similar issues. Malformed redirect URLs from user input not corre ... ... rom the response. In addition, modifications to the Cache-Control header for all Internet Explorer requests with a Content-Disposition header have also been removed as they were found to have similar issues. Malformed redirect URLs from user input not corre ... ... rmissions in templates (#18979) Fixed some Python 2.5 compatibility issues Fixed an issue with quoted filenames in Content-Disposition header (#19006) Made the context option in trans and blocktrans tags accept literals wrapped in single quotes (#18881). Nu ... ... rom the response. In addition, modifications to the Cache-Control header for all Internet Explorer requests with a Content-Disposition header have also been removed as they were found to have similar issues. Issue: Malformed redirect URLs from user input no ... ... に設定された場合、デフォルトでは現在時刻になります。 次の形式で文字列を出力します: Wdy, DD Mon YYYY HH:MM:SS GMT 。 content_disposition_header ( as_attachment , filename ) [ソース] RFC 6266 に指定された filename から Content-Disposition HTTPヘッダー値を構築し ... ます。 as_attachment が False でかつ filename が None の場合は None を返し、それ以外の場合は Content-Disposition HTTPヘッダーに適した文字列を返します。 base36_to_int ( s ) [ソース] base36 文字列を整数に変換します。 int_to_base36 ( i ) ... 2026年10月08日