mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-16 04:28:17 -06:00
Improve API error handling when a list is given as a choice value
See https://groups.google.com/forum/#!topic/netbox-discuss/H7xIrwVnOSM
This commit is contained in:
parent
f18c3be745
commit
e8d4561db1
@ -1,4 +1,5 @@
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Hashable
|
||||
|
||||
import pytz
|
||||
from django.conf import settings
|
||||
@ -101,7 +102,7 @@ class ChoiceField(Field):
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if data not in self._choices:
|
||||
if not isinstance(data, Hashable) or data not in self._choices:
|
||||
raise ValidationError("{} is not a valid choice.".format(data))
|
||||
|
||||
return data
|
||||
|
Loading…
Reference in New Issue
Block a user