aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/relations.py
diff options
context:
space:
mode:
authorTom Christie2014-10-01 21:35:27 +0100
committerTom Christie2014-10-01 21:35:27 +0100
commitffc6aa3abcb0f823b43b63db1666913565e6f934 (patch)
tree353e6e03d370dbf1647a73c8fa3edb7f9562e6b4 /rest_framework/relations.py
parentc171fa21ac62538331755524057d2435f33ec8a5 (diff)
downloaddjango-rest-framework-ffc6aa3abcb0f823b43b63db1666913565e6f934.tar.bz2
More forms support
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()
+ ])