diff options
| author | Tom Christie | 2014-10-01 21:35:27 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-10-01 21:35:27 +0100 |
| commit | ffc6aa3abcb0f823b43b63db1666913565e6f934 (patch) | |
| tree | 353e6e03d370dbf1647a73c8fa3edb7f9562e6b4 /rest_framework/relations.py | |
| parent | c171fa21ac62538331755524057d2435f33ec8a5 (diff) | |
| download | django-rest-framework-ffc6aa3abcb0f823b43b63db1666913565e6f934.tar.bz2 | |
More forms support
Diffstat (limited to 'rest_framework/relations.py')
| -rw-r--r-- | rest_framework/relations.py | 20 |
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() + ]) |
