Enforce consistent ordering of value/label keys for ChoiceField
This commit is contained in:
@@ -71,7 +71,11 @@ class ChoiceField(Field):
|
|||||||
def to_representation(self, obj):
|
def to_representation(self, obj):
|
||||||
if obj is '':
|
if obj is '':
|
||||||
return None
|
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):
|
def to_internal_value(self, data):
|
||||||
# Hotwiring boolean values
|
# Hotwiring boolean values
|
||||||
|
Reference in New Issue
Block a user