From c457f01b198a9a4a31011e42c32433cfb2d5585d Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Fri, 16 Aug 2024 21:29:57 +0700 Subject: [PATCH] 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 --- netbox/netbox/forms/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/netbox/netbox/forms/base.py b/netbox/netbox/forms/base.py index d59f61ef9b9..74ac4b0e005 100644 --- a/netbox/netbox/forms/base.py +++ b/netbox/netbox/forms/base.py @@ -60,6 +60,8 @@ def clean(self): if value in self.fields[cf_name].empty_values: self.instance.custom_field_data[key] = None 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) return super().clean()