python - DRF serializer skips nested serializer validation when many=True -


i have serializer refers serializer many=true. simplified version:

class serializera(serializers.serializer):     id = serializers.charfield()     quantity = serializers.integerfield()  class serializerb(serializers.serializer):     name = serializers.charfield()     items = serializera(many=true, required=true) 

when i'm getting data without items field specified, serializer.is_valid() reason returns true. if 'many' argument set false, validation works expected.

why happening?

i assume you're trying perform put or post. in case, drf not support nested relations out of box , if don't have in field items - validator returns true. should return error if have in items.

to make post/put work need override .create() , .update() method of serializerb.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -