class documentation

class Collector:

Known subclasses: django.contrib.admin.utils.NestedObjects, django.contrib.contenttypes.management.commands.remove_stale_contenttypes.NoFastDeleteCollector

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method ​_has​_signal​_listeners Undocumented
Method add Add 'objs' to the collection of objects to be deleted. If the call is the result of a cascade, 'source' should be the model that caused it, and 'nullable' should be set to True if the relation can be null.
Method add​_dependency Undocumented
Method add​_field​_update Schedule a field update. 'objs' must be a homogeneous iterable collection of model instances (e.g. a QuerySet).
Method add​_restricted​_objects Undocumented
Method can​_fast​_delete Determine if the objects in the given queryset-like or single object can be fast-deleted. This can be done if there are no cascades, no parents and no signal listeners for the object class.
Method clear​_restricted​_objects​_from​_queryset Undocumented
Method clear​_restricted​_objects​_from​_set Undocumented
Method collect No summary
Method delete Undocumented
Method get​_del​_batches Return the objs in suitably sized batches for the used connection.
Method instances​_with​_model Undocumented
Method related​_objects Get a QuerySet of the related model to objs via related fields.
Method sort Undocumented
Instance Variable data Undocumented
Instance Variable dependencies Undocumented
Instance Variable fast​_deletes Undocumented
Instance Variable field​_updates Undocumented
Instance Variable restricted​_objects Undocumented
Instance Variable using Undocumented
def __init__(self, using):

Undocumented

def _has_signal_listeners(self, model):

Undocumented

def add(self, objs, source=None, nullable=False, reverse_dependency=False):

Add 'objs' to the collection of objects to be deleted. If the call is the result of a cascade, 'source' should be the model that caused it, and 'nullable' should be set to True if the relation can be null.

Return a list of all objects that were not already collected.

def add_dependency(self, model, dependency, reverse_dependency=False):

Undocumented

def add_field_update(self, field, value, objs):
Schedule a field update. 'objs' must be a homogeneous iterable collection of model instances (e.g. a QuerySet).
def add_restricted_objects(self, field, objs):

Undocumented

def can_fast_delete(self, objs, from_field=None):

Determine if the objects in the given queryset-like or single object can be fast-deleted. This can be done if there are no cascades, no parents and no signal listeners for the object class.

The 'from_field' tells where we are coming from - we need this to determine if the objects are in fact to be deleted. Allow also skipping parent -> child -> parent chain preventing fast delete of the child.

def clear_restricted_objects_from_queryset(self, model, qs):

Undocumented

def clear_restricted_objects_from_set(self, model, objs):

Undocumented

def collect(self, objs, source=None, nullable=False, collect_related=True, source_attr=None, reverse_dependency=False, keep_parents=False, fail_on_restricted=True):

Add 'objs' to the collection of objects to be deleted as well as all parent instances. 'objs' must be a homogeneous iterable collection of model instances (e.g. a QuerySet). If 'collect_related' is True, related objects will be handled by their respective on_delete handler.

If the call is the result of a cascade, 'source' should be the model that caused it and 'nullable' should be set to True, if the relation can be null.

If 'reverse_dependency' is True, 'source' will be deleted before the current model, rather than after. (Needed for cascading to parent models, the one case in which the cascade follows the forwards direction of an FK rather than the reverse direction.)

If 'keep_parents' is True, data of parent model's will be not deleted.

If 'fail_on_restricted' is False, error won't be raised even if it's prohibited to delete such objects due to RESTRICT, that defers restricted object checking in recursive calls where the top-level call may need to collect more objects to determine whether restricted ones can be deleted.

def delete(self):

Undocumented

def get_del_batches(self, objs, fields):
Return the objs in suitably sized batches for the used connection.
def instances_with_model(self):

Undocumented

def related_objects(self, related_model, related_fields, objs):
Get a QuerySet of the related model to objs via related fields.
def sort(self):

Undocumented

data =

Undocumented

dependencies =

Undocumented

fast_deletes: list =

Undocumented

field_updates =

Undocumented

restricted_objects =

Undocumented

using =

Undocumented