mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 10:03:57 +03:00
Merge pull request #2266 from tomchristie/improve-nested-write-checking
Improve error checking for nested writes.
This commit is contained in:
commit
6158285856
|
@ -611,6 +611,7 @@ def raise_errors_on_nested_writes(method_name, serializer, validated_data):
|
||||||
# profile = ProfileSerializer()
|
# profile = ProfileSerializer()
|
||||||
assert not any(
|
assert not any(
|
||||||
isinstance(field, BaseSerializer) and (key in validated_data)
|
isinstance(field, BaseSerializer) and (key in validated_data)
|
||||||
|
and isinstance(validated_data[key], (list, dict))
|
||||||
for key, field in serializer.fields.items()
|
for key, field in serializer.fields.items()
|
||||||
), (
|
), (
|
||||||
'The `.{method_name}()` method does not support writable nested'
|
'The `.{method_name}()` method does not support writable nested'
|
||||||
|
@ -630,6 +631,7 @@ def raise_errors_on_nested_writes(method_name, serializer, validated_data):
|
||||||
# address = serializer.CharField('profile.address')
|
# address = serializer.CharField('profile.address')
|
||||||
assert not any(
|
assert not any(
|
||||||
'.' in field.source and (key in validated_data)
|
'.' in field.source and (key in validated_data)
|
||||||
|
and isinstance(validated_data[key], (list, dict))
|
||||||
for key, field in serializer.fields.items()
|
for key, field in serializer.fields.items()
|
||||||
), (
|
), (
|
||||||
'The `.{method_name}()` method does not support writable dotted-source '
|
'The `.{method_name}()` method does not support writable dotted-source '
|
||||||
|
|
Loading…
Reference in New Issue
Block a user