Django的事务开启两种方式
#第一种 导入模块
from django.db import transaction
with transaction.atomic():
...
#第二种 装饰器
@transaction.atomic
def post(self,request):
...
sid=transaction.savepoint() #开启事务
...
transaction.savepoint_rollback(sid) # 回滚
...
transaction.savepoint_commit(sid) # 提交