diff --git a/CHANGELOG.md b/CHANGELOG.md index b78e1624a..299e09d7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ NetBox now supports modeling physical cables for console, power, and interface c * [#2601](https://github.com/digitalocean/netbox/issues/2601) - Added a `description` field to pass-through ports * [#2602](https://github.com/digitalocean/netbox/issues/2602) - Return HTTP 204 when no new IPs/prefixes are available for provisioning * [#2608](https://github.com/digitalocean/netbox/issues/2608) - Fixed null `outer_unit` error on rack import +* [#2609](https://github.com/digitalocean/netbox/issues/2609) - Fixed exception when ChoiceField integer value is passed as a string ## API Changes diff --git a/netbox/utilities/api.py b/netbox/utilities/api.py index b788e957e..35dc95a4b 100644 --- a/netbox/utilities/api.py +++ b/netbox/utilities/api.py @@ -78,12 +78,17 @@ class ChoiceField(Field): return data def to_internal_value(self, data): - # Hotwiring boolean values if hasattr(data, 'lower'): + # Hotwiring boolean values from string if data.lower() == 'true': return True if data.lower() == 'false': return False + # Check for string representation of an integer (e.g. "123") + try: + data = int(data) + except ValueError: + pass return data