mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-26 18:38:38 -06:00
Update fields.py
This commit is contained in:
parent
0f0010bac0
commit
ff24bb09af
@ -357,6 +357,10 @@ class DynamicModelChoiceField(DynamicModelChoiceMixin, forms.ModelChoiceField):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def clean(self, value):
|
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':
|
if self.null_option is not None and value == 'null':
|
||||||
return None
|
return None
|
||||||
return super().clean(value)
|
return super().clean(value)
|
||||||
|
Loading…
Reference in New Issue
Block a user