Explorar o código

16640 fix JSON custom field save nul (#16713)

* 16640 fix JSON custom field save nul

* 16640 explicitly check against None

* 16640 convert JSON field from str to dict
Arthur Hanson hai 1 ano
pai
achega
c457f01b19
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      netbox/netbox/forms/base.py

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

@@ -60,6 +60,8 @@ class NetBoxModelForm(CheckLastUpdatedMixin, CustomFieldsMixin, TagsMixin, forms
             if value in self.fields[cf_name].empty_values:
             if value in self.fields[cf_name].empty_values:
                 self.instance.custom_field_data[key] = None
                 self.instance.custom_field_data[key] = None
             else:
             else:
+                if customfield.type == CustomFieldTypeChoices.TYPE_JSON and type(value) is str:
+                    value = json.loads(value)
                 self.instance.custom_field_data[key] = customfield.serialize(value)
                 self.instance.custom_field_data[key] = customfield.serialize(value)
 
 
         return super().clean()
         return super().clean()