Fixes #6131: Correct handling of boolean fields when cloning objects

This commit is contained in:
jeremystretch 2021-04-09 14:42:07 -04:00
parent 4dfba3a2ad
commit 2cc088c633
2 changed files with 4 additions and 3 deletions

View File

@ -16,6 +16,7 @@
* [#6073](https://github.com/netbox-community/netbox/issues/6073) - Permit users to manage their own REST API tokens without needing explicit permission
* [#6081](https://github.com/netbox-community/netbox/issues/6081) - Fix interface connections REST API endpoint
* [#6108](https://github.com/netbox-community/netbox/issues/6108) - Do not infer tenant assignment from parent objects for prefixes, IP addresses
* [#6131](https://github.com/netbox-community/netbox/issues/6131) - Correct handling of boolean fields when cloning objects
---

View File

@ -224,12 +224,12 @@ def prepare_cloned_fields(instance):
field = instance._meta.get_field(field_name)
field_value = field.value_from_object(instance)
# Swap out False with URL-friendly value
# Pass False as null for boolean fields
if field_value is False:
field_value = ''
params.append((field_name, ''))
# Omit empty values
if field_value not in (None, ''):
elif field_value not in (None, ''):
params.append((field_name, field_value))
# Copy tags