@@ -24,7 +24,7 @@ In this guide, you can learn how to use {+django-odm+} to perform
2424**transactions**. Transactions allow you to run a series of operations
2525that change data only if the entire transaction is committed.
2626If any operation in the transaction does not succeed, {+django-odm+} stops the
27- transaction and discards all data changes before they ever become
27+ transaction and discards all changes to the data before they ever become
2828visible. This feature is called **atomicity**.
2929
3030In MongoDB, transactions run within logical sessions. A
@@ -80,10 +80,10 @@ To start a database transaction, define an atomic block of code
8080by adding the ``@transaction.atomic`` decorator above your function.
8181This decorator guarantees the atomicity of any database operations
8282within the function. If the function successfully completes, the
83- changes are committed MongoDB.
83+ changes are committed to MongoDB.
8484
8585The following example calls the ``create()`` method within a transaction,
86- inserting a document into the ``sample_mflix.movies`` collection if the
86+ which inserts a document into the ``sample_mflix.movies`` collection if the
8787transaction succeeds:
8888
8989.. literalinclude:: /includes/interact-data/transactions.py
@@ -105,8 +105,8 @@ preceding example but uses a context manager to start a transaction:
105105Run Callbacks After a Transaction
106106---------------------------------
107107
108- If you want to perform certain actions only if a transaction successfully
109- completes, you can use the ``transaction.on_commit()`` method . This method allows you to
108+ To perform certain actions only if a transaction successfully completes,
109+ you can use the ``transaction.on_commit()`` function . This function allows you to
110110register callbacks that run after a transaction is committed to the
111111database. Pass a function, or any callable object, as an argument to
112112``on_commit()``.
@@ -124,11 +124,12 @@ Handle Transaction Errors
124124-------------------------
125125
126126To handle exceptions that occur during a transaction, add error handling
127- logic around your atomic code block. If you include error handing logic inside
128- the atomic block, {+framework+} might ignore these errors, resulting in unexpected
129- behavior.
127+ logic around your atomic code block. If you handle errors inside
128+ the atomic block, you might obscure these errors from {+framework+}. Since
129+ {+framework+} uses errors to determine whether to commit or roll
130+ back a transaction, this can cause unexpected behavior.
130131
131- If a transaction does not succeed, your application does not revert any changes made
132+ If a transaction does not succeed, Django does not revert any changes made
132133to a model's fields. To avoid inconsistencies between your models and database documents,
133134you might need to manually restore the original field values.
134135
0 commit comments