Python 3.x 在django中,@transaction.atomic auto也应用于嵌套方法
我刚开始学习django,遇到了这种困惑 考虑下面的代码Python 3.x 在django中,@transaction.atomic auto也应用于嵌套方法,python-3.x,django,django-rest-framework,transactions,atomicity,Python 3.x,Django,Django Rest Framework,Transactions,Atomicity,我刚开始学习django,遇到了这种困惑 考虑下面的代码 @transaction.atomic def first_method() doing stuff calling_method() def calling_method() items = item.objects.filter(item_id__in=[list of items]) for item in items: item.save() 上面的代码会在db中逐个
@transaction.atomic
def first_method()
doing stuff
calling_method()
def calling_method()
items = item.objects.filter(item_id__in=[list of items])
for item in items:
item.save()
上面的代码会在db中逐个保存条目记录吗?还是会一次保存所有条目,因为我在第一个方法中使用了@transaction.atomic
如果我必须在db中一次保存所有项目记录,我是否也应该在调用_method()时使用@transaction.atomic