aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorTom Christie2013-12-03 08:03:02 -0800
committerTom Christie2013-12-03 08:03:02 -0800
commit344cd865ab2f0ae04d43ff0fac07cba53b2ca33f (patch)
tree91fa76f26f7afcd3863f3c7543b1f40ce3059214 /rest_framework/fields.py
parentfe4c7d4000675a1720e7d3e02c3014a693d835aa (diff)
parent8d09f56061a3ee82e31fb646cfa84484ae525f88 (diff)
downloaddjango-rest-framework-344cd865ab2f0ae04d43ff0fac07cba53b2ca33f.tar.bz2
Merge pull request #1250 from Ian-Foote/choice_field
Add choices to options metadata for ChoiceField.
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index 463d296f..5a4f04a5 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -514,6 +514,11 @@ class ChoiceField(WritableField):
choices = property(_get_choices, _set_choices)
+ def metadata(self):
+ data = super(ChoiceField, self).metadata()
+ data['choices'] = [{'value': v, 'display_name': n} for v, n in self.choices]
+ return data
+
def validate(self, value):
"""
Validates that the input is in self.choices.