我使用了Django Rest Framework 它只存储数组的最后一个元素,而不是所有3个元素
@api_view(['POST'])
def add(request):
serializer = modelSerializer(data=request.data)
arr = ['a','b','c']
if serializerVariant.is_valid():
obj = serializer.save()
for foo in arr:
obj.value = foo
obj.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializerVariant.errors,status=status.HTTP_400_BAD_REQUEST)