aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/relations.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/relations.py')
-rw-r--r--rest_framework/relations.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/rest_framework/relations.py b/rest_framework/relations.py
index b5effc6c..8c135672 100644
--- a/rest_framework/relations.py
+++ b/rest_framework/relations.py
@@ -38,6 +38,16 @@ class RelatedField(Field):
queryset = queryset.all()
return queryset
+ @property
+ def choices(self):
+ return dict([
+ (
+ str(self.to_representation(item)),
+ str(item)
+ )
+ for item in self.queryset.all()
+ ])
+
class StringRelatedField(Field):
"""
@@ -255,3 +265,13 @@ class ManyRelation(Field):
self.child_relation.to_representation(value)
for value in obj.all()
]
+
+ @property
+ def choices(self):
+ return dict([
+ (
+ str(self.child_relation.to_representation(item)),
+ str(item)
+ )
+ for item in self.child_relation.queryset.all()
+ ])