Moved misplaced transaction.atomic from 0dce44e16b
Thanks Florian Apolloner for noticing the issue and Aymeric Augustin for the expertise. Refs #22540.
This commit is contained in:
parent
3818d96426
commit
faa8c71fd9
|
@ -364,8 +364,7 @@ class QuerySet(object):
|
||||||
"""
|
"""
|
||||||
obj = self.model(**kwargs)
|
obj = self.model(**kwargs)
|
||||||
self._for_write = True
|
self._for_write = True
|
||||||
with transaction.atomic(using=self.db):
|
obj.save(force_insert=True, using=self.db)
|
||||||
obj.save(force_insert=True, using=self.db)
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def bulk_create(self, objs, batch_size=None):
|
def bulk_create(self, objs, batch_size=None):
|
||||||
|
@ -448,7 +447,8 @@ class QuerySet(object):
|
||||||
Used by get_or_create and update_or_create
|
Used by get_or_create and update_or_create
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
obj = self.create(**params)
|
with transaction.atomic(using=self.db):
|
||||||
|
obj = self.create(**params)
|
||||||
return obj, True
|
return obj, True
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
|
|
Loading…
Reference in New Issue