Built-in QuerySet

class safedelete.queryset.SafeDeleteQueryset(model: Optional[Type[django.db.models.base.Model]] = None, query: Optional[safedelete.query.SafeDeleteQuery] = None, using: Optional[str] = None, hints: Optional[Dict[str, django.db.models.base.Model]] = None)[source]

Default queryset for the SafeDeleteManager.

Takes care of “lazily evaluating” safedelete QuerySets. QuerySets passed within the SafeDeleteQueryset will have all of the models available. The deleted policy is evaluated at the very end of the chain when the QuerySet itself is evaluated.

classmethod as_manager()[source]

Override as_manager behavior to ensure we create a SafeDeleteManager.

delete(force_policy: Optional[int] = None) → Tuple[int, Dict[str, int]][source]

Overrides bulk delete behaviour.


The current implementation loses performance on bulk deletes in order to safely delete objects according to the deletion policies set.

See also


undelete(force_policy: Optional[int] = None) → Tuple[int, Dict[str, int]][source]

Undelete all soft deleted models.


The current implementation loses performance on bulk undeletes in order to call the pre/post-save signals.

all(force_visibility=None) → _QS[source]

Override so related managers can also see the deleted models.

A model’s m2m field does not easily have access to all_objects and so setting force_visibility to True is a way of getting all of the models. It is not recommended to use force_visibility outside of related models because it will create a new queryset.

force_visibility: Force a deletion visibility. (default: {None})
filter(*args, **kwargs)[source]

Return a new QuerySet instance with the args ANDed to the existing set.