Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Improve nested update and create testing.
  • Loading branch information
lovelydinosaur committed Dec 3, 2014
commit e1d98f77563abf49c4b19dcfb95f263515ae4087
6 changes: 3 additions & 3 deletions rest_framework/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ def create(self, validated_attrs):
# If we don't do this explicitly they'd likely get a confusing
# error at the point of calling `Model.objects.create()`.
assert not any(
isinstance(field, BaseSerializer) and not field.read_only
for field in self.fields.values()
isinstance(field, BaseSerializer) and (key in validated_attrs)
for key, field in self.fields.items()
), (
'The `.create()` method does not suport nested writable fields '
'by default. Write an explicit `.create()` method for serializer '
Expand Down Expand Up @@ -682,7 +682,7 @@ def create(self, validated_attrs):
def update(self, instance, validated_attrs):
assert not any(
isinstance(field, BaseSerializer) and (key in validated_attrs)
for key, field in self.fields.values()
for key, field in self.fields.items()
), (
'The `.update()` method does not suport nested writable fields '
'by default. Write an explicit `.update()` method for serializer '
Expand Down