... ons in a Django project, see the Using CSP documentation. For an HTTP guide about CSP, see the MDN Guide on CSP . 概要 The Content-Security-Policy specification defines two complementary headers: Content-Security-Policy : Enforces the CSP policy, blocki ... ng content that violates the defined directives. Content-Security-Policy-Report-Only : Reports CSP violations without blocking conten ... omposed of one or more directives and their values, which together instruct the browser on how to handle specific types of content. When the ContentSecurityPolicyMiddleware is enabled, Django automatically builds and attaches the appropriate headers to ... ... するときに使用するコンテキストデータ。 これは dict でなければなりません。 例: {'foo': 123} SimpleTemplateResponse. rendered_content [ソース] 現在のテンプレートとコンテキストデータを使ってレンダリングされた、レスポンスコンテンツの現在の値。 SimpleTemplate ... ンスの内容がレンダリングされたかどうかを示す真偽値。 メソッド SimpleTemplateResponse. __init__ ( template , context = None , content_type = None , status = None , charset = None , using = None , headers = None ) [ソース] SimpleTemplateResponse オブジェクト ... template, or a list of template names. context テンプレートコンテキストに追加する値の dict 。デフォルトでは空の辞書です。 content_type HTTP の Content-Type ヘッダに含まれる値で、MIME タイプ指定と文字セットエンコーディングを含みます。もし content_type が ... ... core.mail import EmailMultiAlternatives from django.template.loader import render_to_string # First, render the plain text content. text_content = render_to_string ( "templates/emails/my_email.txt" , context = { "my_variable" : 42 }, ) # Secondly, rende ... r the HTML content. html_content = render_to_string ( "templates/emails/my_email.html" , context = { "my_variable" : 42 }, ) # Then, create a ... multipart email instance. msg = EmailMultiAlternatives ( subject = "Subject here" , body = text_content , from_email = "from@example.com" , to = [ "to@example.com" ], headers = { "List-Unsubscribe" : "<mailto:unsub@example.com ... ... ing 値を使用します。フォームデータが DEFAULT_CHARSET エンコーディングでないことがわかっている場合に便利です。 HttpRequest. content_type リクエストの MIME タイプを表す文字列です。 CONTENT_TYPE から識別されます。 HttpRequest. content_params CONTENT_TYPE ヘ ... ヘッダーが格納されたディクショナリです。利用可能なヘッダーはクライアントとサーバーによって異なりますが、以下に例を示します。 CONTENT_LENGTH -- リクエスト本文の (文字列としての) 長さです。 CONTENT_TYPE -- リクエスト本文の MIME タイプです。 HTTP_ACCEPT -- レ ... や "POST" といったです。 SERVER_NAME -- サーバのホスト名です。 SERVER_PORT -- (文字列としての) サーバのポートです。 上記の CONTENT_LENGTH と CONTENT_TYPE を除き、リクエストの HTTP ヘッダーは、すべての文字を大文字に変換し、ハイフンをアンダースコアに置き換 ... ... types アプリケーションの中心にあるのは、 django.contrib.contenttypes.models.ContentType にある ContentType モデルです。 ContentType のインスタンスは、プロジェクトにインストールされたモデ ... ルに関する情報を表し、格納します。新しい ContentType のインスタンスは、新しいモデルがインストールされるたびに自動的に作成されます。 ContentType のインスタンスは ContentTyp ... e が表すモデルクラスを返すメソッドと、それらのモデルからオブジェクトを問い合わせるメソッドを持っています。また、 ContentType を操作するためのメソッドや、特定のモデルの ContentType のインスタンスを取得するためのメソッドを追加する カスタムマネー ... ... れたファイルの名前 (例: my_file.txt )。 UploadedFile. size アップロードされたファイルのサイズ(バイト単位)。 UploadedFile. content_type ファイルと共にアップロードされるコンテンツタイプのヘッダ (例: text/plain や application/pdf )。ユーザーから提供される ... がコンテンツタイプヘッダが示すコンテンツを含んでいることを検証する必要があります。"信頼するが検証せよ" です。 UploadedFile. content_type_extra content-type ヘッダーに渡される追加のパラメータを含む辞書です。通常、Google App Engine などのサービスがファイル ... サイズを使用します。 デフォルトは 64*2 10 bytes、つまり 64 KB です。 FileUploadHandler. new_file ( field_name , file_name , content_type , content_length , charset , content_type_extra ) [ソース] 新しいファイルのアップロード開始を通知するコールバックです ... ... _view() dispatch() head() http_method_not_allowed() setup() TemplateView class TemplateView 属性 (とオプションのアクセサ): content_type extra_context http_method_names response_class [ render_to_response() ] template_engine template_name [ get_template_ ... _method_not_allowed() options() post() put() setup() 詳細ビュー DetailView class DetailView 属性 (とオプションのアクセサ): content_type context_object_name [ get_context_object_name() ] extra_context http_method_names model pk_url_kwarg query_pk_and_slu ... o_response() setup() リストビュー ListView class ListView 属性 (とオプションのアクセサ): allow_empty [ get_allow_empty() ] content_type context_object_name [ get_context_object_name() ] extra_context http_method_names model ordering [ get_ordering() ] p ... ... uest ): f = request . FILES [ "file_field_name" ] ... ...you'd need to make the following changes: Old (0.96) New (1.0) f['content'] f.read() f['filename'] f.name f['content-type'] f.content_type Work with file fields using the new API The internal impl ... ill need to make the following changes, assuming your model's FileField is called myfile : Old (0.96) New (1.0) myfile.get_content_filename() myfile.content.path myfile.get_content_url() myfile.content.url myfile.get_content_size() myfile.content.size m ... yfile.save_content_file() myfile.content.save() myfile.get_content_width() myfile.content.width myfile.get_content_height() myfile.content.he ... ... te a streaming response by passing an iterator to HttpResponse . But this was unreliable: any middleware that accessed the content attribute would consume the iterator prematurely. You can now explicitly generate a streaming response with the new Stream ... ingHttpResponse class. This class exposes a streaming_content attribute which is an iterator. Since StreamingHttpResponse does not have a content attribute, middleware that needs acces ... s to the response content must test for streaming responses and behave accordingly. {% verbatim %} template tag To make it easier to deal with JavaS ... ... nse def some_view ( request ): # Create the HttpResponse object with the appropriate CSV header. response = HttpResponse ( content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) writer = csv . writ ... HTML と解釈し、ブラウザウィンドウに醜くて恐ろしいぐちゃぐちゃの文字列が現れてしまう恐れがあります。 レスポンスには、追加の Content-Disposition ヘッダに CSV のファイル名を設定することができます。ファイル名はどんなものでも構いません。ここで指定した名前は、 ... 0 ): yield "" . join ( writer . writerow ( row ) for row in batch ) return StreamingHttpResponse ( stream_batched_rows (), content_type = "text/csv" , headers = { "Content-Disposition" : 'attachment; filename="somefilename.csv"' }, ) テンプレートシステム ... 2026年10月08日