mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
17406 allow deletion of plugin custom field if plugin removed
This commit is contained in:
parent
893adef79c
commit
48ca5d4d7e
@ -295,10 +295,11 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
|
|||||||
"""
|
"""
|
||||||
for ct in content_types:
|
for ct in content_types:
|
||||||
model = ct.model_class()
|
model = ct.model_class()
|
||||||
instances = model.objects.filter(custom_field_data__has_key=self.name)
|
if model:
|
||||||
for instance in instances:
|
instances = model.objects.filter(custom_field_data__has_key=self.name)
|
||||||
del instance.custom_field_data[self.name]
|
for instance in instances:
|
||||||
model.objects.bulk_update(instances, ['custom_field_data'], batch_size=100)
|
del instance.custom_field_data[self.name]
|
||||||
|
model.objects.bulk_update(instances, ['custom_field_data'], batch_size=100)
|
||||||
|
|
||||||
def rename_object_data(self, old_name, new_name):
|
def rename_object_data(self, old_name, new_name):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user