... 属性 (とオプションのアクセサ): content_type extra_context http_method_names response_class [ render_to_response() ] template_engine template_name [ get_template_names() ] メソッド as_view() dispatch() get() get_context_data() head() http_method_not_allow ... ueryset [ get_queryset() ] response_class [ render_to_response() ] slug_field [ get_slug_field() ] slug_url_kwarg template_engine template_name [ get_template_names() ] template_name_field template_name_suffix メソッド as_view() dispatch() get() get_co ... ns [ get_paginate_orphans() ] paginator_class queryset [ get_queryset() ] response_class [ render_to_response() ] template_engine template_name [ get_template_names() ] template_name_suffix メソッド as_view() dispatch() get() get_context_data() get_pag ... ... Django テンプレート言語入門 からスタートしてください。 概要 Pythonでテンプレートシステムを使うには3つのステップがあります: Engine を設定します。 テンプレートコードを Template にコンパイルします。 テンプレートを Context においてレンダリングします。 これ ... クエンドに依存しない高レベルの API に依存しています: TEMPLATES 設定の中で、各 DjangoTemplates バックエンドに対して、Djangoは Engine をインスタンス化します。 DjangoTemplates は Engine をラップし、共通のテンプレートバックエンドAPIに適応させます。 django.te ... し DjangoTemplates バックエンドを使っているのであれば、これはおそらくあなたが探しているドキュメントではありません。後述する Engine クラスのインスタンスには、そのバックエンドの engine 属性を使ってアクセスすることができ、後述する属性のデフォルトは DjangoT ... ... eEngine を継承したクラスです。このクラスは get_template() と、オプションで from_string() を実装する必要があります。以下は架空の fo ... 例です: from django.template import TemplateDoesNotExist , TemplateSyntaxError from django.template.backends.base import BaseEngine from django.template.backends.utils import csrf_input_lazy , csrf_token_lazy import foobar class FooBar ( BaseEngine ): # ... Name of the subdirectory containing the templates for this engine # inside an installed application. app_dirname = "foobar" def __init__ ( self , params ): params = params . copy () option ... ... それらを DATABASES 内のデータベース設定の OPTIONS 部分で指定しなければなりません。 settings.py DATABASES = { "default" : { "ENGINE" : "django.db.backends.postgresql" , "OPTIONS" : { "service" : "my_service" , "passfile" : ".my_pgpass" , }, } } .pg_servi ... 必要がある場合は、次のように DATABASES 内のデータベース設定の OPTIONS 部分で指定してください。 DATABASES = { "default" : { "ENGINE" : "django.db.backends.postgresql" , # ... "OPTIONS" : { "assume_role" : "my_application_role" , }, }, } 接続プール Connec ... tionary of options to pass to ConnectionPool , or to True to use the ConnectionPool defaults: DATABASES = { "default" : { "ENGINE" : "django.db.backends.postgresql" , # ... "OPTIONS" : { "pool" : True , }, }, } The CONN_MAX_AGE setting must be 0 when c ... ... いう名前の MySQL データベースを定義した settings.py スニペットの例です。 DATABASES = { "default" : { "NAME" : "app_data" , "ENGINE" : "django.db.backends.postgresql" , "USER" : "postgres_user" , "PASSWORD" : "s3krit" , }, "users" : { "NAME" : "user_data ... " , "ENGINE" : "django.db.backends.mysql" , "USER" : "mysql_user" , "PASSWORD" : "priv4te" , }, } default データベースという概念がプロ ... ータベースを定義している settings.py スニペットの例です。 DATABASES = { "default" : {}, "users" : { "NAME" : "user_data" , "ENGINE" : "django.db.backends.mysql" , "USER" : "mysql_user" , "PASSWORD" : "superS3cret" , }, "customers" : { "NAME" : "customer ... ... のは、Django テンプレート言語の API の概要です。詳細については、 API リファレンス をご覧ください。 エンジン django.template.Engine は Django テンプレートシステムのインスタンスをカプセル化します。 Engine を直接インスタンス化する主な理由は、 Django プロジ ... ェクトの外で Django テンプレート言語を使うためです。 django.template.backends.django.DjangoTemplates は、 django.template.Engine を Django のテンプレートバックエンド API に適応させる薄いラッパーです。 テンプレート django.template.Template はコンパイル ... されたテンプレートを表します。テンプレートは Engine.get_template() または Engine.from_string() で取得できます。 同様に django.template.backends.django.Template は django.temp ... ... シュを使用し、データがキャッシュから削除されている場合にはデータベースを使用します。このバックエンドを使用するには、 SESSION_ENGINE を "django.contrib.sessions.backends.cached_db" に設定し、 using database-backed sessions の構成手順に従ってください。 キャ ... れる可能性があり、ユーザーのログアウトを含めてセッションデータが失われることになります。このバックエンドを使うには、 SESSION_ENGINE を "django.contrib.sessions.backends.cache" に設定してください。 キャッシュバックエンドを永続化するには、Redis などの永続キ ... 起こされるエッジケースを避けることができます。 ファイルを使ったセッション ファイルを使ったセッションを使用するには、 SESSION_ENGINE を "django.contrib.sessions.backends.file" に設定します。 Django がセッションファイルを保存する場所を設定したい場合には、 ... ... rate, backwards-compatible backend, called "mysql_old", has been added to Django. To use this backend, change the DATABASE_ENGINE setting in your Django settings file from this: DATABASE_ENGINE = "mysql" to this: DATABASE_ENGINE = "mysql_old" However, ... ... レートの完全な名前。 template_name を定義しないと、 django.core.exceptions.ImproperlyConfigured 例外が発生します。 template_engine テンプレートを読み込む際に使用するテンプレートエンジンの NAME です。 template_engine は response_class の using キーワード ... ... 1.2) format, you had a number of DATABASE_ settings in your settings file. For example: DATABASE_NAME = "test_db" DATABASE_ENGINE = "postgresql_psycopg2" DATABASE_USER = "myusername" DATABASE_PASSWORD = "s3krit" These settings are now in a dictionary n ... o been shortened. The previous sample settings would now look like this: DATABASES = { "default" : { "NAME" : "test_db" , "ENGINE" : "django.db.backends.postgresql_psycopg2" , "USER" : "myusername" , "PASSWORD" : "s3krit" , } } This affects the followi ... ng settings: Old setting New Setting DATABASE_ENGINE ENGINE DATABASE_HOST HOST DATABASE_NAME NAME DATABASE_OPTIONS OPTIONS DATABASE_PASSWORD PASSWORD DATABASE_PORT PORT DATABA ... 2026年10月08日