Closed
Description
Hello,
We have a use case where we accept either a list of objects or null. The problem is that BaseSerializer.many_init
is not passing the allow_null
argument to the ListSerializer
constructor. because of that I have validation errors even if the field was specified with allow_null=True
.
He's an example:
class PaymentInfoSerializer(serializers.Serializer):
url = serializer.CharField()
amount = serializers.DecimalField()
def validate(self, attrs):
"""
This is never being called
"""
class Request(serializers.Serializer):
payment_info = PaymentInfoSerializer(
many=True,
required=False,
allow_null=True)
Basically LIST_SERIALIZER_KWARGS
(defined here) does not include allow_null
and therefore the arguments is not passed to the ListSerializer
constructor (details here).
Is there a reason why allow_null
should not be sent to the list serializer?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels