From 60a4e1fd8144f5f5b4ada227852c50073e9cde29 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 24 Mar 2025 12:46:24 -0400 Subject: [PATCH] remove_stale_data() should validate model class --- netbox/extras/models/customfields.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/netbox/extras/models/customfields.py b/netbox/extras/models/customfields.py index 721c4ae54..7f064f639 100644 --- a/netbox/extras/models/customfields.py +++ b/netbox/extras/models/customfields.py @@ -304,9 +304,10 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel): no longer assigned to a model, or because it has been deleted). """ for ct in content_types: - ct.model_class().objects.update( - custom_field_data=F('custom_field_data') - self.name - ) + if model := ct.model_class(): + model.objects.update( + custom_field_data=F('custom_field_data') - self.name + ) def rename_object_data(self, old_name, new_name): """