mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-15 10:42:24 +03:00
fix: MultipleChoiceField use ordered sort
(cherry picked from commit 8436483e66
)
This commit is contained in:
parent
3038494705
commit
cc77c105b7
|
@ -1469,17 +1469,17 @@ class MultipleChoiceField(ChoiceField):
|
||||||
if not self.allow_empty and len(data) == 0:
|
if not self.allow_empty and len(data) == 0:
|
||||||
self.fail('empty')
|
self.fail('empty')
|
||||||
|
|
||||||
return {
|
# Arguments for super() are needed because of scoping inside
|
||||||
# Arguments for super() are needed because of scoping inside
|
# comprehensions.
|
||||||
# comprehensions.
|
return list(dict.fromkeys([
|
||||||
super(MultipleChoiceField, self).to_internal_value(item)
|
super(MultipleChoiceField, self).to_internal_value(item)
|
||||||
for item in data
|
for item in data
|
||||||
}
|
]))
|
||||||
|
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
return {
|
return list(dict.fromkeys([
|
||||||
self.choice_strings_to_values.get(str(item), item) for item in value
|
self.choice_strings_to_values.get(str(item), item) for item in value
|
||||||
}
|
]))
|
||||||
|
|
||||||
|
|
||||||
class FilePathField(ChoiceField):
|
class FilePathField(ChoiceField):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user