Skip to content

Fix missing validated_data in raise_errors_on_nested_writes (#2221) #2224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rest_framework/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def errors(self):
# ModelSerializer & HyperlinkedModelSerializer
# --------------------------------------------

def raise_errors_on_nested_writes(method_name, serializer):
def raise_errors_on_nested_writes(method_name, serializer, validated_data):
"""
Give explicit errors when users attempt to pass writable nested data.

Expand All @@ -586,7 +586,7 @@ def raise_errors_on_nested_writes(method_name, serializer):
# ...
# profile = ProfileSerializer()
assert not any(
isinstance(field, BaseSerializer) and (key in validated_attrs)
isinstance(field, BaseSerializer) and (key in validated_data)
for key, field in serializer.fields.items()
), (
'The `.{method_name}()` method does not support writable nested'
Expand All @@ -605,7 +605,7 @@ def raise_errors_on_nested_writes(method_name, serializer):
# ...
# address = serializer.CharField('profile.address')
assert not any(
'.' in field.source and (key in validated_attrs)
'.' in field.source and (key in validated_data)
for key, field in serializer.fields.items()
), (
'The `.{method_name}()` method does not support writable dotted-source '
Expand Down Expand Up @@ -682,7 +682,7 @@ def create(self, validated_data):
If you want to support writable nested relationships you'll need
to write an explicit `.create()` method.
"""
raise_errors_on_nested_writes('create', self)
raise_errors_on_nested_writes('create', self, validated_data)

ModelClass = self.Meta.model

Expand Down Expand Up @@ -722,7 +722,7 @@ def create(self, validated_data):
return instance

def update(self, instance, validated_data):
raise_errors_on_nested_writes('update', self)
raise_errors_on_nested_writes('update', self, validated_data)

for attr, value in validated_data.items():
setattr(instance, attr, value)
Expand Down