... ョンを扱う一般的な方法は、各リクエストをトランザクションでラップすることです。この動作を有効化したい各データベースの設定で、 ATOMIC_REQUESTS を True にセットしてください。 これは、次のように動作します。まず、ビュー関数を呼び出す前に、Django はトランザクシ ... ンをコミットします。もしビューが例外を生成した場合は、Django はトランザクションをロールバックします。 ビューのコード (通常は atomic() コンテキストマネージャー) の中で、セーブポイントを使ったサブトランザクションを扱うことができます。ただし、ビューの最後で ... ポンスを送信開始した後にエラーを扱う適切な方法が存在しないからです。 実際には、この機能はすべてのビュー関数を以下で説明する atomic() デコレータでラップします。 あなたのビューの実行だけがトランザクションで閉じられることに注意してください。ミドルウェアはト ... ... ョンを扱う一般的な方法は、各リクエストをトランザクションでラップすることです。この動作を有効化したい各データベースの設定で、 ATOMIC_REQUESTS を True にセットしてください。 これは、次のように動作します。まず、ビュー関数を呼び出す前に、Django はトランザクシ ... ンをコミットします。もしビューが例外を生成した場合は、Django はトランザクションをロールバックします。 ビューのコード (通常は atomic() コンテキストマネージャー) の中で、セーブポイントを使ったサブトランザクションを扱うことができます。ただし、ビューの最後で ... ポンスを送信開始した後にエラーを扱う適切な方法が存在しないからです。 実際には、この機能はすべてのビュー関数を以下で説明する atomic() デコレータでラップします。 あなたのビューの実行だけがトランザクションで閉じられることに注意してください。ミドルウェアはト ... ... では、マイグレーションはデフォルトでトランザクション内で実行されます。大きなテーブルに対してデータ移行を行う場合などには、 atomic 属性を False に設定することで、トランザクション内で移行が実行されないようにすることができます: from django.db import migra ... tions class Migration ( migrations . Migration ): atomic = False Within such a migration, all operations are run without a transaction. It's possible to execute parts of the migra ... tion inside a transaction using atomic() or by passing atomic=True to RunPython . 以下は、大きなテーブルを小さなバッチで更新する、非アトミックなデータマイグレーシ ... ... では、マイグレーションはデフォルトでトランザクション内で実行されます。大きなテーブルに対してデータ移行を行う場合などには、 atomic 属性を False に設定することで、トランザクション内で移行が実行されないようにすることができます: from django.db import migra ... tions class Migration ( migrations . Migration ): atomic = False Within such a migration, all operations are run without a transaction. It's possible to execute parts of the migra ... tion inside a transaction using atomic() or by passing atomic=True to RunPython . 以下は、大きなテーブルを小さなバッチで更新する、非アトミックなデータマイグレーシ ... ... ango.db.models.functions.Now を補完するもので、現在のステートメントの日時を返します。 Note that only the outermost call to atomic() sets up a transaction and thus sets the time that TransactionNow() will return; nested calls create savepoints which do ... ... ango.db.models.functions.Now を補完するもので、現在のステートメントの日時を返します。 Note that only the outermost call to atomic() sets up a transaction and thus sets the time that TransactionNow() will return; nested calls create savepoints which do ... ... ns now allow using transforms. See 式はトランスフォーム(Transform)を参照できる for details. The new durable argument for atomic() guarantees that changes made in the atomic block will be committed if the block exits without errors. A nested atomic bl ... ... der this simplified example: @task def my_task ( thing_num ): Thing . objects . get ( num = thing_num ) with transaction . atomic (): Thing . objects . create ( num = 1 ) my_task . enqueue ( thing_num = 1 ) To prevent the scenario where my_task runs be ... to enqueue() via functools.partial() : from functools import partial from django.db import transaction with transaction . atomic (): Thing . objects . create ( num = 1 ) transaction . on_commit ( partial ( my_task . enqueue , thing_num = 1 )) Task res ... ... ns now allow using transforms. See 式はトランスフォーム(Transform)を参照できる for details. The new durable argument for atomic() guarantees that changes made in the atomic block will be committed if the block exits without errors. A nested atomic bl ... ... der this simplified example: @task def my_task ( thing_num ): Thing . objects . get ( num = thing_num ) with transaction . atomic (): Thing . objects . create ( num = 1 ) my_task . enqueue ( thing_num = 1 ) To prevent the scenario where my_task runs be ... to enqueue() via functools.partial() : from functools import partial from django.db import transaction with transaction . atomic (): Thing . objects . create ( num = 1 ) transaction . on_commit ( partial ( my_task . enqueue , thing_num = 1 )) Task res ... 2026年10月08日