Sfoglia il codice sorgente

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 11 anni fa
parent
commit
5bf8aeb25b
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  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.