Explorar el Código

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

Jeremy Stretch hace 7 años
padre
commit
c51c20a301
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  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]}
 
     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