17406 allow deletion of plugin custom field if plugin removed

This commit is contained in:
Arthur Hanson 2024-09-13 09:29:46 -07:00 committed by Jeremy Stretch
parent 893adef79c
commit 48ca5d4d7e

View File

@ -295,10 +295,11 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
"""
for ct in content_types:
model = ct.model_class()
instances = model.objects.filter(custom_field_data__has_key=self.name)
for instance in instances:
del instance.custom_field_data[self.name]
model.objects.bulk_update(instances, ['custom_field_data'], batch_size=100)
if model:
instances = model.objects.filter(custom_field_data__has_key=self.name)
for instance in instances:
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):
"""