Przeglądaj źródła

Fixes #2319: Extend ChoiceField to properly handle true/false choice keys

Jeremy Stretch 7 lat temu
rodzic
commit
c51c20a301
1 zmienionych plików z 6 dodań i 0 usunięć
  1. 6 0
      netbox/utilities/api.py

+ 6 - 0
netbox/utilities/api.py

@@ -74,6 +74,12 @@ class ChoiceField(Field):
         return {'value': obj, 'label': self._choices[obj]}
         return {'value': obj, 'label': self._choices[obj]}
 
 
     def to_internal_value(self, data):
     def to_internal_value(self, data):
+        # Hotwiring boolean values
+        if hasattr(data, 'lower'):
+            if data.lower() == 'true':
+                return True
+            if data.lower() == 'false':
+                return False
         return data
         return data