Explorar o código

Fixed calling pre_save in BulkUpdateModelMixin

The pre_save trigger is performed on single objects, however in BulkUpdateModelMixin it was called with a list of objects as argument
Arien Tolner %!s(int64=11) %!d(string=hai) anos
pai
achega
5bf8aeb25b
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      rest_framework_bulk/mixins.py

+ 1 - 1
rest_framework_bulk/mixins.py

@@ -50,7 +50,7 @@ class BulkUpdateModelMixin(object):
 
         if serializer.is_valid():
             try:
-                self.pre_save(serializer.object)
+                [self.pre_save(obj) for obj in serializer.object]
             except ValidationError as err:
                 # full_clean on model instances may be called in pre_save
                 # so we have to handle eventual errors.