... この例では、以下のメソッドは topping.pizza_set と pizza.toppings の両方で利用できます。 add ( * objs , bulk = True , through_defaults = None ) aadd ( * objs , bulk = True , through_defaults = None ) 非同期バージョン : aadd() リレーション先オブジェクトのセッ ... 合、 add() は *objs 引数としてモデルインスタンスかフィールドの値(通常は主キー)を受け付けます。 必要であれば、引数 through_defaults を使用して、新しい 中間モデル インスタンスの値を指定します。呼び出し可能オブジェクトを through_defaults 辞書の値として使用 ... することができ、中間インスタンスを作成する前に一度だけ評価されます。 create ( through_defaults = None , ** kwargs ) acreate ( through_defaults = None , ** kwargs ) 非同期バージョン : acreate() 新しいオブジェクトを作成 ... ... The @task decorator defines a Task instance. All keyword arguments are passed directly to the backend's task_class (which defaults to Task ). The following standard arguments are supported: priority : Sets the priority of the Task . Defaults to 0. queue ... _name : Sets the queue_name of the Task . Defaults to "default" . backend : Sets the backend of the Task . Defaults to "default" . takes_context : Controls whether the Task ... function accepts a TaskContext . Defaults to False . See Task context for details. Custom Task backends may define a custom task_class that accepts additional argum ... ... れらを独自のカスタムビューで上書きするには、 エラービューをカスタマイズする を参照してください。 404 (page not found) ビュー defaults. page_not_found ( request , exception , template_name = '404.html' ) ビュー内で Http404 を発生させると、 Django は 404 エラ ... ーの処理に特化した特別なビューを読み込みます。デフォルトでは django.views.defaults.page_not_found() というビューで、"Not Found" メッセージを表示するか、ルートテンプレートディレクトリにテンプレート 404.html ... (設定モジュール内)、404ビューは使用されず、代わりに URLconf がデバッグ情報と共に表示されます。 500(サーバーエラー)ビュー defaults. server_error ( request , template_name = '500.html' ) 同様に、Django はビューコードで実行時エラーが発生した場合、特別なケ ... ... である必要があるためです。手動の主キーを使用している場合は、例外処理に備える必要があります。 get_or_create() get_or_create ( defaults = None , ** kwargs ) aget_or_create ( defaults = None , ** kwargs ) 非同期バージョン : aget_or_create() 与えられた kwargs ... に書き換えることができます: obj , created = Person . objects . get_or_create ( first_name = "John" , last_name = "Lennon" , defaults = { "birthday" : date ( 1940 , 10 , 9 )}, ) Any keyword arguments passed to get_or_create() — except an optional one calle ... d defaults — will be used in a get() call. If an object is found, get_or_create() returns a tuple of that object and False . 警告 この ... ... 呼び出し時の default_settings 引数(または最初の位置引数)として渡すことができます。 この例では、デフォルトの設定は myapp_defaults から取得され、 DEBUG 設定は myapp_defaults での値に関係なく True に設定されます: from django.conf import settings from mya ... pp import myapp_defaults settings . configure ( default_settings = myapp_defaults , DEBUG = True ) 次の例では、 myapp_defaults を位置引数として使っ ... ていますが、等価です: settings . configure ( myapp_defaults , DEBUG = True ) 通常、このような方法でデフォルトを上書きする必要はありません。Django のデフォ ルトは十分に無難なので、安全 ... ... uest.headers now allows lookups using underscores (e.g. user_agent ) in place of hyphens. セキュリティ X_FRAME_OPTIONS now defaults to 'DENY' . In older versions, the X_FRAME_OPTIONS setting defaults to 'SAMEORIGIN' . If your site uses frames of itself, ... eption allows controlling whether or not exceptions raised during the request should also be raised in the test. The value defaults to True for backwards compatibility. If it is False and an exception occurs, the test client will return a 500 response wi ... hod or QuerySet.filter(pk=…).update(…) instead. For example: >>> MyModel . objects . update_or_create ( pk = existing_pk , defaults = { "name" : "new name" }) >>> MyModel . objects . filter ( pk = existing_pk ) . update ( name = "new name" ) データベース ... ... ンポートパスを表す文字列です。 HTTPクライアントがリクエストを送信した場合に該当します。 デフォルトでは、これは django.views.defaults.bad_request() です。カスタムビューを実装する場合は、 request および exception 引数を受け入れ、 HttpResponseBadRequest を返 ... 限を持っていない場合に呼び出されるべきビューの完全な Python インポートパスを表す文字列。 デフォルトでは、これは django.views.defaults.permission_denied() です。カスタムビューを実装する場合には、 request と exception 引数を受け入れ、 HttpResponseForbidden を ... するものがない場合に呼び出されるべきビューへの完全な Python インポートパスを表す文字列。 デフォルトでは、これは django.views.defaults.page_not_found() です。カスタムビューを実装する場合は、 request と exception 引数を受け取り、 HttpResponseNotFound を返すよ ... ... callables were allowed). This allows a much more natural use of URLconfs. For example, this URLconf: from django.conf.urls.defaults import * urlpatterns = patterns ( "" , ( "^myview/$" , "mysite.myapp.views.myview" )) can now be rewritten as: from django ... .conf.urls.defaults import * from mysite.myapp.views import myview urlpatterns = patterns ( "" , ( "^myview/$" , myview )) One useful applicat ... y decorators to views in your URLconf . Thus, you can make a generic view require login very easily: from django.conf.urls.defaults import * from django.contrib.auth.decorators import login_required from django.views.generic.list_detail import object_lis ... ... ar on the default page generated by the django.views.defaults.page_not_found() view. The URL path is no longer displayed in the default 404 template and the request_path context variab ... ... rySet.update_or_create() と QuerySet.aupdate_or_create() メソッドに、作成操作のために異なるフィールド値を指定できる create_defaults 引数が追加されました。 BaseConstraint 、 CheckConstraint 、および UniqueConstraint に violation_error_code 属性が追加され、 ... ついて説明します。 データベースがデフォルトでデータベース関数をサポートしていない場合、 DatabaseFeatures.supports_expression_defaults を False に設定する必要があります。 データベースが INSERT クエリ内で DEFAULT キーワードをサポートしていない場合、 Database ... ートが削除されました。Django 5.0 は MySQL 8.0.11 以上をサポートします。 QuerySet.update_or_create() を使用する際に、 create_defaults__exact を必要とする場合があります。 QuerySet.update_or_create() は、パラメータ create_defaults をサポートするようになりまし ... 2026年10月08日