mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-13 05:06:53 +03:00
Merge pull request #3086 from vstoykov/fix-manyrelated-choices
Fix ManyRelatedField.choices
This commit is contained in:
commit
5833a1847f
|
@ -388,16 +388,4 @@ class ManyRelatedField(Field):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def choices(self):
|
def choices(self):
|
||||||
queryset = self.child_relation.queryset
|
return self.child_relation.choices
|
||||||
iterable = queryset.all() if (hasattr(queryset, 'all')) else queryset
|
|
||||||
items_and_representations = [
|
|
||||||
(item, self.child_relation.to_representation(item))
|
|
||||||
for item in iterable
|
|
||||||
]
|
|
||||||
return OrderedDict([
|
|
||||||
(
|
|
||||||
six.text_type(item_representation),
|
|
||||||
six.text_type(item) + ' - ' + six.text_type(item_representation)
|
|
||||||
)
|
|
||||||
for item, item_representation in items_and_representations
|
|
||||||
])
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user