Просмотр исходного кода

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

jeremystretch 3 лет назад
Родитель
Сommit
ad78f9e075
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      netbox/netbox/forms/base.py

+ 3 - 0
netbox/netbox/forms/base.py

@@ -48,6 +48,9 @@ class NetBoxModelForm(BootstrapMixin, CustomFieldsMixin, forms.ModelForm):
 
         # Save custom field data on instance
         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
             value = self.cleaned_data.get(cf_name)