3π
β
Per the docs:
The ListSerializer class provides the behavior for serializing and
validating multiple objects at once. You wonβt typically need to use
ListSerializer directly, but should instead simply pass many=True when
instantiating a serializer
You can add many=True
to your serializer
class FileSerializer(serializers.ModelSerializer):
def __init__(self, *args, **kwargs):
kwargs['many'] = kwargs.get('many', True)
super().__init__(*args, **kwargs)
Potential dupe of How do I create multiple model instances with Django Rest Framework?
π€Sam Sunde
Source:stackexchange.com