django中如何开启事务&启动锁

django开启事务

# 先导入模块
from django.db import transaction

# 开启事务
try:
	with transaction.atomic():
		操作数据库的代码块
		(出现异常会回滚)
except Exception as e:
	出现异常会执行下面的代码

image

django开启锁

image

posted @ 2023-08-11 15:08  等日落  阅读(7)  评论(0编辑  收藏  举报