I am using DRF for my API backend. I need to insert multiple objects into one post request. I saw so many tutorials, as well How do I create multiple model instances with Django Rest Framework?, but not success. I am using ModelSerializer, but when using many=True then have problem with ListSerializer.
views.py
class SaleUserViewSet(ModelViewSet):
queryset = SaleUser.objects.all()
serializer_class = SaleUserSerializer(many=True)
serlializers.py
class SaleUserSerializer(serializers.ModelSerializer):
class Meta:
model = SaleUser
fields = ('id', 'comment', 'creation_date', 'modification_date', 'last_user', 'user', 'sale', 'user_sale_type')
error message
AttributeError at /api/sale_user/ type object 'Meta' has no attribute 'model'
Please advise.
rollback serializer to your default
and override view to it: