mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 18:09:59 +03:00
Fix dotted-source field checking on serializer write
The code was previously checking the validated data for the field's attribute name, however, the data contain the first source attr.
This commit is contained in:
parent
8f44c5c630
commit
aa7941470a
|
@ -819,10 +819,10 @@ 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
|
len(field.source_attrs) > 1 and
|
||||||
(key in validated_data) and
|
(field.source_attrs[0] in validated_data) and
|
||||||
isinstance(validated_data[key], (list, dict))
|
isinstance(validated_data[field.source_attrs[0]], (list, dict))
|
||||||
for key, field in serializer.fields.items()
|
for field in serializer._writable_fields
|
||||||
), (
|
), (
|
||||||
'The `.{method_name}()` method does not support writable dotted-source '
|
'The `.{method_name}()` method does not support writable dotted-source '
|
||||||
'fields by default.\nWrite an explicit `.{method_name}()` method for '
|
'fields by default.\nWrite an explicit `.{method_name}()` method for '
|
||||||
|
|
Loading…
Reference in New Issue
Block a user