批量插入数据

roduct_list_to_insert = list()
for x in range(10):
    product_list_to_insert.append(Product(name='product name ' + str(x), price=x))
Product.objects.bulk_create(product_list_to_insert)
posted @ 2018-12-17 17:58  学习python1234  阅读(94)  评论(0编辑  收藏  举报
levels of contents