Django nested transactions - “with transaction.atomic()”

与世无争的帅哥 提交于 2019-12-04 22:13:55

Yes, it will. Regardless of nesting, if an atomic block is exited by an exception it will roll back:

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.

Note also that an exception in an outer block will cause the inner block to roll back, and that an exception in an inner block can be caught to prevent the outer block from rolling back. The documentation addresses these issues. (Or see here for a more comprehensive follow-up question on nested transactions).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!