1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Enforce consistent ordering of value/label keys for ChoiceField

This commit is contained in:
Jeremy Stretch
2018-11-26 14:02:38 -05:00
parent a46f68c6e4
commit 2bae50f501

View File

@ -71,7 +71,11 @@ class ChoiceField(Field):
def to_representation(self, obj):
if obj is '':
return None
return {'value': obj, 'label': self._choices[obj]}
data = OrderedDict([
('value', obj),
('label', self._choices[obj])
])
return data
def to_internal_value(self, data):
# Hotwiring boolean values