I have such serializers
class MyModelSerializer(serializers.ModelSerializer):
class Meta:
model = MyModel
fields = ('id',)
class MyModelIdListSerializer(serializers.Serializer):
ids = MyModelSerializer(many=True)
And request body like
{
"ids": [
{
"id": "f07e3673-6631-4139-90da-331773ba868e"
},
{
"id": "f07e3673-6631-4139-90da-331773ba868e"
}
]
}
But need this
{
"ids": [
"f07e3673-6631-4139-90da-331773ba868e",
"f07e3673-6631-4139-90da-331773ba868e"
]
}
I can do ListField with UUID as child but need to write custom validate if such id exists on table
If you want list of ids
use PrimaryKeyRelatedField
ids = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With