diff options
| author | Tom Christie | 2013-03-08 21:20:52 +0000 | 
|---|---|---|
| committer | Tom Christie | 2013-03-08 21:20:52 +0000 | 
| commit | 53b58a50599bde2798b9d6deef0cd5bfc6ed2488 (patch) | |
| tree | cb7216ce5a3cdd0c96f6c65c88e764527760d406 /rest_framework/serializers.py | |
| parent | c5b98f0d106758298edf045e7bb44ecd7e4b9629 (diff) | |
| parent | 66605acaf02d46eb899f495137afb4f9ff127ff0 (diff) | |
| download | django-rest-framework-53b58a50599bde2798b9d6deef0cd5bfc6ed2488.tar.bz2 | |
Merge branch 'master' of https://github.com/bitmonkey/django-rest-framework into list-deserialization
Diffstat (limited to 'rest_framework/serializers.py')
| -rw-r--r-- | rest_framework/serializers.py | 17 | 
1 files changed, 12 insertions, 5 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index ba9e9e9c..80287522 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -286,8 +286,18 @@ class BaseSerializer(Field):          Deserialize primitives -> objects.          """          if hasattr(data, '__iter__') and not isinstance(data, (dict, six.text_type)): -            # TODO: error data when deserializing lists -            return [self.from_native(item, None) for item in data] +            object_list = list() +            error_list = list() +            for count, item in enumerate(data): +                obj = self.from_native(item, None) +                if self._errors: +                    error_list.append((count, self._errors)) +                object_list.append(obj) +            if not error_list: +                return object_list + +            self._errors = error_list +            return None          self._errors = {}          if data is not None or files is not None: @@ -354,9 +364,6 @@ class BaseSerializer(Field):                                    'Use the `many=True` flag when instantiating the serializer.',                                    PendingDeprecationWarning, stacklevel=3) -            # TODO: error data when deserializing lists -            if many: -                ret = [self.from_native(item, None) for item in data]              ret = self.from_native(data, files)              if not self._errors:  | 
