mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Raise warnings on implicit many serialization
This commit is contained in:
parent
f642ee48a6
commit
388e617366
|
@ -344,6 +344,10 @@ class BaseSerializer(Field):
|
||||||
many = self.many
|
many = self.many
|
||||||
else:
|
else:
|
||||||
many = hasattr(data, '__iter__') and not isinstance(data, (Page, dict))
|
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
|
# TODO: error data when deserializing lists
|
||||||
if many:
|
if many:
|
||||||
|
@ -369,6 +373,10 @@ class BaseSerializer(Field):
|
||||||
many = self.many
|
many = self.many
|
||||||
else:
|
else:
|
||||||
many = hasattr(obj, '__iter__') and not isinstance(obj, (Page, dict))
|
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:
|
if many:
|
||||||
self._data = [self.to_native(item) for item in obj]
|
self._data = [self.to_native(item) for item in obj]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user