Selaa lähdekoodia

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

jeremystretch 4 vuotta sitten
vanhempi
commit
2cc088c633
2 muutettua tiedostoa jossa 4 lisäystä ja 3 poistoa
  1. 1 0
      docs/release-notes/version-2.10.md
  2. 3 3
      netbox/utilities/utils.py

+ 1 - 0
docs/release-notes/version-2.10.md

@@ -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
 
 ---
 

+ 3 - 3
netbox/utilities/utils.py

@@ -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