mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Fixes #15548: Ignore many-to-many mappings when checking dependencies of an object being deleted
This commit is contained in:
parent
cbfed83f60
commit
0e3c35ae58
@ -339,10 +339,14 @@ class ObjectDeleteView(GetReturnURLMixin, BaseObjectView):
|
||||
|
||||
# Compile a mapping of models to instances
|
||||
dependent_objects = defaultdict(list)
|
||||
for model, instance in collector.instances_with_model():
|
||||
for model, instances in collector.instances_with_model():
|
||||
# Ignore relations to auto-created models (e.g. many-to-many mappings)
|
||||
if model._meta.auto_created:
|
||||
continue
|
||||
# Omit the root object
|
||||
if instance != obj:
|
||||
dependent_objects[model].append(instance)
|
||||
if instances == obj:
|
||||
continue
|
||||
dependent_objects[model].append(instances)
|
||||
|
||||
return dict(dependent_objects)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user