object save needs to be atomic transaction so entire object is saved
This commit is contained in:
parent
7a2854317e
commit
7c5ad70781
1 changed files with 23 additions and 22 deletions
|
@ -4,7 +4,7 @@ from collections import OrderedDict
|
|||
from functools import reduce, wraps
|
||||
from itertools import chain
|
||||
|
||||
from django.db import models
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Field, FieldDoesNotExist, Manager, ManyToManyRel, Prefetch, Q
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
|
@ -276,6 +276,7 @@ class ModelInstanceWrapper(BaseWrapper):
|
|||
author = self._author
|
||||
if self.pk is None:
|
||||
self._changeset.add_create(self, author=author)
|
||||
with transaction.atomic():
|
||||
for field, initial_value in self._initial_values.items():
|
||||
if field.many_to_one:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue