diff --git a/safedelete/models.py b/safedelete/models.py index 30a693a..c534bd8 100644 --- a/safedelete/models.py +++ b/safedelete/models.py @@ -234,8 +234,10 @@ def soft_delete_cascade_policy_action(self, **kwargs) -> Tuple[int, Dict[str, in deleted_counter: Counter = Counter() for related in related_objects(self): if is_safedelete_cls(related.__class__) and not getattr(related, FIELD_NAME): - _, delete_response = related.delete(force_policy=SOFT_DELETE, is_cascade=True, **kwargs) - deleted_counter.update(delete_response) + res = related.delete(force_policy=SOFT_DELETE, is_cascade=True, **kwargs) + if res is not None: + _, delete_response = res + deleted_counter.update(delete_response) # soft-delete the object _, delete_response = self._delete(force_policy=SOFT_DELETE, **kwargs) diff --git a/safedelete/queryset.py b/safedelete/queryset.py index 5b0c99d..3b78cd0 100644 --- a/safedelete/queryset.py +++ b/safedelete/queryset.py @@ -61,8 +61,10 @@ def delete(self, force_policy: Optional[int] = None) -> Tuple[int, Dict[str, int deleted_counter: Counter = Counter() # TODO: Replace this by bulk update if we can for obj in self.all(): - _, delete_response = obj.delete(force_policy=force_policy) - deleted_counter.update(delete_response) + res = obj.delete(force_policy=force_policy) + if res is not None: + _, delete_response = res + deleted_counter.update(delete_response) self._result_cache = None return sum(deleted_counter.values()), dict(deleted_counter) delete.alters_data = True # type: ignore