Commit 2f6e5d05 by James Beith

Add display value method

Returns the text representation of the instance. Subclasses can override this method to provide a different display value used for populating the `choices` property.
parent 0cbfbc27
......@@ -148,7 +148,7 @@ class RelatedField(Field):
return OrderedDict([
(
six.text_type(self.to_representation(item)),
six.text_type(item)
six.text_type(self.display_value(item))
)
for item in queryset
])
......@@ -160,6 +160,9 @@ class RelatedField(Field):
def iter_options(self):
return iter_options(self.grouped_choices)
def display_value(self, instance):
return six.text_type(instance)
class StringRelatedField(RelatedField):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment