Is “transaction.atomic” same as “transaction.commit_on_success”?

前端 未结 2 758
忘掉有多难
忘掉有多难 2020-12-05 03:35

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 manag

2条回答
  •  醉梦人生
    2020-12-05 04:22

    Yes. You should use atomic in the places where you previously used commit_on_success.

    Since the new transaction system is designed to be more robust and consistent, though, it's possible that you could see different behavior. For example, if you catch database errors and try to continue on you will see a TransactionManagementError, whereas the previous behavior was undefined and probably case-dependent.

    But, if you're doing things properly, everything should continue to work the same way.

提交回复
热议问题