Skip to content

Commit 2cc088c

Browse files
committed
Fixes #6131: Correct handling of boolean fields when cloning objects
1 parent 4dfba3a commit 2cc088c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

docs/release-notes/version-2.10.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* [#6073](https://github.com/netbox-community/netbox/issues/6073) - Permit users to manage their own REST API tokens without needing explicit permission
1717
* [#6081](https://github.com/netbox-community/netbox/issues/6081) - Fix interface connections REST API endpoint
1818
* [#6108](https://github.com/netbox-community/netbox/issues/6108) - Do not infer tenant assignment from parent objects for prefixes, IP addresses
19+
* [#6131](https://github.com/netbox-community/netbox/issues/6131) - Correct handling of boolean fields when cloning objects
1920

2021
---
2122

netbox/utilities/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,12 @@ def prepare_cloned_fields(instance):
224224
field = instance._meta.get_field(field_name)
225225
field_value = field.value_from_object(instance)
226226

227-
# Swap out False with URL-friendly value
227+
# Pass False as null for boolean fields
228228
if field_value is False:
229-
field_value = ''
229+
params.append((field_name, ''))
230230

231231
# Omit empty values
232-
if field_value not in (None, ''):
232+
elif field_value not in (None, ''):
233233
params.append((field_name, field_value))
234234

235235
# Copy tags

0 commit comments

Comments
 (0)