From c51c20a301686e589d3c0d2e017f1a0ce2154222 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 7 Aug 2018 13:48:29 -0400 Subject: [PATCH] Fixes #2319: Extend ChoiceField to properly handle true/false choice keys --- netbox/utilities/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netbox/utilities/api.py b/netbox/utilities/api.py index 0ce207d6e..d753954aa 100644 --- a/netbox/utilities/api.py +++ b/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