... sing = None ) [ソース] ¶ このデコレータは、与えられたビューのために ATOMIC_REQUESTS を無効化します。 from django.db import transaction @transaction . non_atomic_requests def my_view ( request ): do_stuff () @transaction . non_atomic_requests ( using = "othe ... ックの中に入れ子になっている場合、 RuntimeError が発生します。 atomic is usable both as a decorator : from django.db import transaction @transaction . atomic def viewfunc ( request ): # This code executes inside a transaction. do_stuff () and as a context ma ... nager : from django.db import transaction def viewfunc ( request ): # This code executes in autocommit mode (Django's default). do_stuff () with transaction . atomi ... ... sing = None ) [ソース] ¶ このデコレータは、与えられたビューのために ATOMIC_REQUESTS を無効化します。 from django.db import transaction @transaction . non_atomic_requests def my_view ( request ): do_stuff () @transaction . non_atomic_requests ( using = "othe ... ックの中に入れ子になっている場合、 RuntimeError が発生します。 atomic is usable both as a decorator : from django.db import transaction @transaction . atomic def viewfunc ( request ): # This code executes inside a transaction. do_stuff () and as a context ma ... nager : from django.db import transaction def viewfunc ( request ): # This code executes in autocommit mode (Django's default). do_stuff () with transaction . atomi ... ... faults to SQLite. If the default templates don't suit your tastes, you can use custom project and app templates . Improved transaction management ¶ Django's transaction management was overhauled. Database-level autocommit is now turned on by default. This m ... akes transaction handling more explicit and should improve performance. The existing APIs were deprecated, and new APIs were introduced, as ... described in the transaction management docs . Persistent database connections ¶ Django now supports reusing the same database connection for several r ... ... faults to SQLite. If the default templates don't suit your tastes, you can use custom project and app templates . Improved transaction management ¶ Django's transaction management was overhauled. Database-level autocommit is now turned on by default. This m ... akes transaction handling more explicit and should improve performance. The existing APIs were deprecated, and new APIs were introduced, as ... described in the transaction management docs . Persistent database connections ¶ Django now supports reusing the same database connection for several r ... ... u want to continue to use the base unittest library, you can -- you just won't get any of the nice new unittest2 features. Transaction context managers ¶ Users of Python 2.5 and above may now use transaction management functions as context managers. For exa ... mple: with transaction . autocommit (): ... Configurable delete-cascade ¶ ForeignKey and OneToOneField now accept an on_delete argument to custom ... also delete the file from the backend storage. This opened the door to several data-loss scenarios, including rolled-back transactions and fields on different models referencing the same file. In Django 1.3, when a model is deleted the FileField 's delete( ... ... u want to continue to use the base unittest library, you can -- you just won't get any of the nice new unittest2 features. Transaction context managers ¶ Users of Python 2.5 and above may now use transaction management functions as context managers. For exa ... mple: with transaction . autocommit (): ... Configurable delete-cascade ¶ ForeignKey and OneToOneField now accept an on_delete argument to custom ... also delete the file from the backend storage. This opened the door to several data-loss scenarios, including rolled-back transactions and fields on different models referencing the same file. In Django 1.3, when a model is deleted the FileField 's delete( ... ... django.db.models.functions.UUID4 is a cross-database version of this function. RandomUUID may be deprecated in the future. TransactionNow ¶ class TransactionNow [ソース] ¶ 現在のトランザクションが開始されたデータベースサーバー上の日時を返します。トランザクシ ... tions.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 not affect the transacti ... on time. 使用例: >>> from django.contrib.postgres.functions import TransactionNow >>> Article . objects . filter ( published__lte = TransactionNow ()) <QuerySet [<Article: How to Django>]> 目次 Postgre ... ... django.db.models.functions.UUID4 is a cross-database version of this function. RandomUUID may be deprecated in the future. TransactionNow ¶ class TransactionNow [ソース] ¶ 現在のトランザクションが開始されたデータベースサーバー上の日時を返します。トランザクシ ... tions.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 not affect the transacti ... on time. 使用例: >>> from django.contrib.postgres.functions import TransactionNow >>> Article . objects . filter ( published__lte = TransactionNow ()) <QuerySet [<Article: How to Django>]> 目次 Postgre ... ... ランザクション ¶ For most backends, Tasks are run in a separate process, using a different database connection. When using a transaction, without waiting for it to commit, workers could start to process a Task which uses objects it can't access yet. For examp ... le, consider 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_tas ... k runs before the Thing is committed to the database, use transaction.on_commit() , binding all arguments to enqueue() via functools.partial() : from functools import partial from django.db im ... ... ランザクション ¶ For most backends, Tasks are run in a separate process, using a different database connection. When using a transaction, without waiting for it to commit, workers could start to process a Task which uses objects it can't access yet. For examp ... le, consider 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_tas ... k runs before the Thing is committed to the database, use transaction.on_commit() , binding all arguments to enqueue() via functools.partial() : from functools import partial from django.db im ... 2026年10月08日