From ff24bb09afec41348c91c7c33912287069b5882e Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Thu, 11 Feb 2021 08:58:30 -0600 Subject: [PATCH] Update fields.py --- netbox/utilities/forms/fields.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netbox/utilities/forms/fields.py b/netbox/utilities/forms/fields.py index 3cf421213..055fc62ab 100644 --- a/netbox/utilities/forms/fields.py +++ b/netbox/utilities/forms/fields.py @@ -357,6 +357,10 @@ class DynamicModelChoiceField(DynamicModelChoiceMixin, forms.ModelChoiceField): """ def clean(self, value): + """ + When null option is enabled and "None" is sent as part of a form to be submitted, it is sent as the + string 'null'. This will check for that condition and gracefully handle the conversion to a NoneType. + """ if self.null_option is not None and value == 'null': return None return super().clean(value)