17406 allow deletion of plugin custom field if plugin removed

This commit is contained in:
Arthur Hanson 2024-09-13 09:31:21 -07:00 committed by Jeremy Stretch
parent 48ca5d4d7e
commit f5d6f5d997

View File

@ -294,8 +294,7 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
no longer assigned to a model, or because it has been deleted).
"""
for ct in content_types:
model = ct.model_class()
if model:
if 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]