Skip to content

Commit

Permalink
Preserve ordering on relationship drop-down choices. Closes #2408.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Jan 14, 2015
1 parent 41e13d7 commit 4ce4132
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rest_framework/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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
Expand Down Expand Up @@ -103,7 +104,7 @@ def get_attribute(self, instance):

@property
def choices(self):
return dict([
return OrderedDict([
(
six.text_type(self.to_representation(item)),
six.text_type(item)
Expand Down Expand Up @@ -364,7 +365,7 @@ def choices(self):
(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)
Expand Down

0 comments on commit 4ce4132

Please sign in to comment.