diff options
| author | Tom Christie | 2013-12-03 08:03:02 -0800 |
|---|---|---|
| committer | Tom Christie | 2013-12-03 08:03:02 -0800 |
| commit | 344cd865ab2f0ae04d43ff0fac07cba53b2ca33f (patch) | |
| tree | 91fa76f26f7afcd3863f3c7543b1f40ce3059214 /rest_framework/fields.py | |
| parent | fe4c7d4000675a1720e7d3e02c3014a693d835aa (diff) | |
| parent | 8d09f56061a3ee82e31fb646cfa84484ae525f88 (diff) | |
| download | django-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.py | 5 |
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. |
