Unfortunately I'm facing the same problem as mentioned in this post. But it didn't solve the problem in my case.
My model:
class AppointmentCategory(models.Model):
name = models.CharField(max_length=100, default='General')
My Serializer:
class AppointmentCategorySerializer(serializers.ModelSerializer):
class Meta:
model = AppointmentCategory
fields = ('id', 'name',)
My View:
class AppointmentCategoryViewSet(viewsets.ModelViewSet):
queryset = AppointmentCategory.objects.all()
serializer_class = AppointmentCategorySerializer(many=True)
I'm passing the post data in this format:
[
{
"name": "Emergency"
},
{
"name": "General"
}
]
It does work when I send only one element. However the above mentioned list fails to create two objects in the database. The error says:
'ListSerializer' object is not callable
I'm not sure how to solve this. Any ideas?