diff options
| author | Tom Christie | 2014-09-22 14:54:33 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-09-22 14:54:33 +0100 |
| commit | 249253a144ba4381581809fb3f27959c7bd6e577 (patch) | |
| tree | 2af20e6b13a344a1af960b2453e1678dcf63b40f /rest_framework | |
| parent | c54f394904c3f93211b8aa073de4e9e50110f831 (diff) | |
| download | django-rest-framework-249253a144ba4381581809fb3f27959c7bd6e577.tar.bz2 | |
Fix compat issues
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/fields.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5105dfcb..5fb99a42 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -209,8 +209,10 @@ class Field(object): """ Validate a simple representation and return the internal value. - The provided data may be `empty` if no representation was included. - May return `empty` if the field should not be included in the + The provided data may be `empty` if no representation was included + in the input. + + May raise `SkipField` if the field should not be included in the validated data. """ if data is empty: @@ -223,6 +225,10 @@ class Field(object): return value def run_validators(self, value): + """ + Test the given value against all the validators on the field, + and either raise a `ValidationError` or simply return. + """ if value in (None, '', [], (), {}): return @@ -753,8 +759,9 @@ class MultipleChoiceField(ChoiceField): } def to_internal_value(self, data): - if not hasattr(data, '__iter__'): + if isinstance(data, type('')) or not hasattr(data, '__iter__'): self.fail('not_a_list', input_type=type(data).__name__) + return set([ super(MultipleChoiceField, self).to_internal_value(item) for item in data |
