Fixes: #5315 - Make "null_option" on DynamicModelChoiceField also null the value on the model.

This commit is contained in:
Daniel Sheppard 2021-01-27 09:21:00 -06:00
parent 1964073072
commit 0f0010bac0
2 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,13 @@
# NetBox v2.10
## v2.10.5 (FUTURE)
### Bug Fixes
* [#5315](https://github.com/netbox-community/netbox/issues/5315) - Fix site unassignment from VLAN when using "None" option
---
## v2.10.4 (2021-01-26)
### Enhancements

View File

@ -355,7 +355,11 @@ class DynamicModelChoiceField(DynamicModelChoiceMixin, forms.ModelChoiceField):
Override get_bound_field() to avoid pre-populating field choices with a SQL query. The field will be
rendered only with choices set via bound data. Choices are populated on-demand via the APISelect widget.
"""
pass
def clean(self, value):
if self.null_option is not None and value == 'null':
return None
return super().clean(value)
class DynamicModelMultipleChoiceField(DynamicModelChoiceMixin, forms.ModelMultipleChoiceField):