I am trying to use transaction.atomic with Django without any luck I know I
am doing something wrong but I don't know what.
class SnapshotView(BaseViewSet):
serializer_class = SnapshotSerializer
@transaction.atomic
def perform_create(self, serializer):
# this will call serializer.save()
snapshot = snapshot = super().perform_create(serializer)
# this will run some code can raise an exception
SnapshotServices.create_snapshot(snapshot=snapshot,
data=serializer.initial_data)
the first method that creates a new snapshot will pass the second will
raise but still, I can see my snapshot instance in the DB, why is that? I
am in transaction block and something fails, is Django not suppose to do a
rollback?
the second method will throw a custom exception I read the doc and it seems
that I am doing everything right.
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.