Skip to content

Commit

Permalink
Merge pull request #2224 from linovia/bugfix/2221
Browse files Browse the repository at this point in the history
Fix missing validated_data in `raise_errors_on_nested_writes` (#2221)
  • Loading branch information
tomchristie committed Dec 7, 2014
2 parents 71c49fe + a257b04 commit 8553858
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 8553858

Please sign in to comment.