From 388e6173669a295214a718e55dbf467559835dee Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 12 Feb 2013 13:53:45 +0000 Subject: [PATCH] Raise warnings on implicit many serialization --- rest_framework/serializers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 0a2e103f9..d59bcfd3f 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -344,6 +344,10 @@ class BaseSerializer(Field): many = self.many else: many = hasattr(data, '__iter__') and not isinstance(data, (Page, dict)) + if many: + warnings.warn('Implict list/queryset serialization is due to be deprecated. ' + 'Use the `many=True` flag when instantiating the serializer.', + PendingDeprecationWarning, stacklevel=2) # TODO: error data when deserializing lists if many: @@ -369,6 +373,10 @@ class BaseSerializer(Field): many = self.many else: many = hasattr(obj, '__iter__') and not isinstance(obj, (Page, dict)) + if many: + warnings.warn('Implict list/queryset serialization is due to be deprecated. ' + 'Use the `many=True` flag when instantiating the serializer.', + PendingDeprecationWarning, stacklevel=2) if many: self._data = [self.to_native(item) for item in obj]