add read_only check for dotted-source fields in serializers

The error message tells that you should create an own crate() function
or set read_only=True for the field. The Problem is that the check
ignores the read_only flag.
This commit is contained in:
Ben Oswald 2014-12-13 18:09:21 +01:00
parent eb78da4b54
commit 0e42c2e663

View File

@ -629,7 +629,7 @@ def raise_errors_on_nested_writes(method_name, serializer, validated_data):
# ...
# address = serializer.CharField('profile.address')
assert not any(
'.' in field.source and (key in validated_data)
'.' in field.source and (key in validated_data) and (field.read_only is not True)
for key, field in serializer.fields.items()
), (
'The `.{method_name}()` method does not support writable dotted-source '