File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -633,8 +633,8 @@ def create(self, validated_attrs):
633
633
# If we don't do this explicitly they'd likely get a confusing
634
634
# error at the point of calling `Model.objects.create()`.
635
635
assert not any (
636
- isinstance (field , BaseSerializer ) and not field . read_only
637
- for field in self .fields .values ()
636
+ isinstance (field , BaseSerializer ) and ( key in validated_attrs )
637
+ for key , field in self .fields .items ()
638
638
), (
639
639
'The `.create()` method does not suport nested writable fields '
640
640
'by default. Write an explicit `.create()` method for serializer '
@@ -681,8 +681,8 @@ def create(self, validated_attrs):
681
681
682
682
def update (self , instance , validated_attrs ):
683
683
assert not any (
684
- isinstance (field , BaseSerializer ) and not field . read_only
685
- for field in self .fields .values ()
684
+ isinstance (field , BaseSerializer ) and ( key in validated_attrs )
685
+ for key , field in self .fields .items ()
686
686
), (
687
687
'The `.update()` method does not suport nested writable fields '
688
688
'by default. Write an explicit `.update()` method for serializer '
You can’t perform that action at this time.
0 commit comments