예제 #1
0
 def create(self, validated_data):
     vectors_data = validated_data.pop('vectors')
     obj = self.Meta.model.objects.create(**validated_data)
     vectors = (Vector(instance=obj, **vector_data)
                for vector_data in vectors_data)
     Vector.objects.bulk_create(vectors)
     return obj
예제 #2
0
    def create(self, validated_data):
        vectors_data = validated_data.pop('vectors', [])
        annotations_data = validated_data.pop('annotations', [])

        obj = self.Meta.model.objects.create(**validated_data)
        vectors = (Vector(instance=obj,
                          file_version=validated_data['file_version'],
                          **vector_data) for vector_data in vectors_data)
        Vector.objects.bulk_create(vectors)
        annotations = (Annotation(instance=obj, **annotation_data)
                       for annotation_data in annotations_data)
        Annotation.objects.bulk_create(annotations)
        return obj