Partial update method now is also transactional as its friend update method.
parent
72eae39c53
commit
d296387651
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import reversion
|
||||
|
||||
from django.db import transaction
|
||||
|
||||
from rest_framework import viewsets
|
||||
|
@ -10,7 +12,6 @@ from rest_framework.response import Response
|
|||
|
||||
from reversion.revisions import revision_context_manager
|
||||
from reversion.models import Version
|
||||
import reversion
|
||||
|
||||
|
||||
from . import pagination
|
||||
|
@ -18,6 +19,8 @@ from . import serializers
|
|||
from . import decorators
|
||||
|
||||
|
||||
# Transactional version of rest framework mixins.
|
||||
|
||||
class CreateModelMixin(mixins.CreateModelMixin):
|
||||
@transaction.atomic
|
||||
def create(self, *args, **kwargs):
|
||||
|
@ -35,6 +38,9 @@ class UpdateModelMixin(mixins.UpdateModelMixin):
|
|||
def update(self, *args, **kwargs):
|
||||
return super().update(*args, **kwargs)
|
||||
|
||||
@transaction.atomic
|
||||
def partial_update(self, request, *args, **kwargs):
|
||||
return super().partial_update(request, *args, **kwargs)
|
||||
|
||||
class ListModelMixin(mixins.ListModelMixin):
|
||||
@transaction.atomic
|
||||
|
|
Loading…
Reference in New Issue