diff options
| author | Tom Christie | 2015-01-14 12:56:03 +0000 |
|---|---|---|
| committer | Tom Christie | 2015-01-14 12:56:03 +0000 |
| commit | 4ce4132e08ba7764f120c71eeebdbaefee281689 (patch) | |
| tree | 254c439be684129f54849f9b08f9191032267101 /rest_framework | |
| parent | 41e13d73fa53863e0aa25d41c32cc10cd4fe89df (diff) | |
| download | django-rest-framework-4ce4132e08ba7764f120c71eeebdbaefee281689.tar.bz2 | |
Preserve ordering on relationship drop-down choices. Closes #2408.
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/relations.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/rest_framework/relations.py b/rest_framework/relations.py index 7b119291..aa0c2def 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -7,6 +7,7 @@ from django.utils import six from django.utils.encoding import smart_text from django.utils.six.moves.urllib import parse as urlparse from django.utils.translation import ugettext_lazy as _ +from rest_framework.compat import OrderedDict from rest_framework.fields import get_attribute, empty, Field from rest_framework.reverse import reverse from rest_framework.utils import html @@ -103,7 +104,7 @@ class RelatedField(Field): @property def choices(self): - return dict([ + return OrderedDict([ ( six.text_type(self.to_representation(item)), six.text_type(item) @@ -364,7 +365,7 @@ class ManyRelatedField(Field): (item, self.child_relation.to_representation(item)) for item in iterable ] - return dict([ + return OrderedDict([ ( six.text_type(item_representation), six.text_type(item) + ' - ' + six.text_type(item_representation) |
