There seems to be a lot of documentation out there on this but none of it seems to work for me. I am trying to build an API View that creates one or many objects at the same time.
Something like passing in the following:
[
{
"response": "I have no favourites",
"user": 1,
"update": "64c5fe6f-cb65-493d-8ef4-126db0195c33",
"question": "297b46b4-714b-4434-b4e6-668ff926b38e"
},
{
"response": "Good",
"user": 1,
"update": "64c5fe6f-cb65-493d-8ef4-126db0195c33",
"question": "13916052-690e-4638-bb7c-908c38dcd75e"
}
]
My current Viewset
class FeedbackViewSet(viewsets.ModelViewSet):
permission_classes = [AllowAny]
queryset = Feedback.objects.all()
serializer_class = FeedbackSerializer
and Serializer:
class ContributionSerializer(serializers.ModelSerializer):
class Meta:
model = Contribution
fields = '__all__'
I have tried setting FeedbackSerializer(many=True)
but this then tells me its not callable. Further, I have tried a ListCreateAPIView
but this tells me it expects a dictionary but not a list.