#7961: Fix updating via import when custom fields are absent

This commit is contained in:
jeremystretch 2022-12-12 14:19:27 -05:00
parent 3468e8c8ae
commit ad78f9e075

View File

@ -48,6 +48,9 @@ class NetBoxModelForm(BootstrapMixin, CustomFieldsMixin, forms.ModelForm):
# Save custom field data on instance # Save custom field data on instance
for cf_name, customfield in self.custom_fields.items(): for cf_name, customfield in self.custom_fields.items():
if cf_name not in self.fields:
# Custom fields may be absent when performing bulk updates via import
continue
key = cf_name[3:] # Strip "cf_" from field name key = cf_name[3:] # Strip "cf_" from field name
value = self.cleaned_data.get(cf_name) value = self.cleaned_data.get(cf_name)