Django 1.6 proposes @transaction.atomic
as part of the rehaul in the transaction management from 1.5.
I have a function which is called by a Django management command which is in turn called by cron, i.e. no HTTP request triggering transactions in this case. Snippet:
from django.db import transaction
@transaction.commit_on_success
def my_function():
# code here
In the above code block commit_on_success
uses a single transaction for all the work done in my_function
.
Does replacing @transaction.commit_on_success
with @transaction.atomic
result in the identical behaviour? @transaction.atomic
docs state:
Atomicity is the defining property of database transactions. atomic allows us to create a block of code within which the atomicity on the database is guaranteed. If the block of code is successfully completed, the changes are committed to the database. If there is an exception, the changes are rolled back.
I take it that they result in the same behaviour; correct?