标签:而不是 bsp ted any 数组 col ida date else
class TrackListSerializer(serializers.ListSerializer): def create(self, validated_data): #validated_data会返回所有请求数组,而不是单个对象 print(validated_data) books = [Track(**item) for item in validated_data] return Track.objects.bulk_create(books) def to_internal_value(self, data): print(‘to_internal_value‘,data) return data.get(‘data‘) class TrackSerializer(serializers.ModelSerializer): # album = AlbumField(queryset=Album.objects.all()) class AlbumSerilaizer(serializers.ModelSerializer): class Meta: model = Album fields = "__all__" album = AlbumSerilaizer(many=False,read_only=True) class Meta: model = Track fields = "__all__" list_serializer_class = TrackListSerializer
标签:而不是 bsp ted any 数组 col ida date else
原文地址:https://www.cnblogs.com/zhouze/p/11491015.html