Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CustomListSerializer(serializers.ListSerializer):
- def __init__(self, *args, **kwargs):
- count = kwargs.pop('count', None)
- self.count = count
- super().__init__(*args, **kwargs)
- def to_representation(self, data):
- if self.count is not None:
- if len(data) != self.count:
- raise serializers.ValidationError("Incorrect list size")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement