Skip to content
Snippets Groups Projects
Commit 505aada8 authored by Benoit Alessandroni's avatar Benoit Alessandroni
Browse files

Merge branch 'transaction-create' into 'master'

bugfix: Serializer.create completed in a transaction

See merge request !172
parents 236e2055 ae8652a3
No related branches found
No related tags found
1 merge request!172bugfix: Serializer.create completed in a transaction
Pipeline #8128 passed
......@@ -8,6 +8,7 @@ from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.exceptions import ImproperlyConfigured
from django.core.exceptions import ValidationError as DjangoValidationError
from django.db import transaction
from django.urls import resolve, Resolver404, get_script_prefix
from django.urls.resolvers import get_resolver
from django.db.models import QuerySet
......@@ -588,9 +589,9 @@ class LDPSerializer(HyperlinkedModelSerializer):
return super().get_value(dictionary)
def create(self, validated_data):
instance = self.internal_create(validated_data, model=self.Meta.model)
self.attach_related_object(instance, validated_data)
with transaction.atomic():
instance = self.internal_create(validated_data, model=self.Meta.model)
self.attach_related_object(instance, validated_data)
return instance
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment