Bulk create model objects in django

后端 未结 8 1896
执笔经年
执笔经年 2020-12-13 05:17

I have a lot of objects to save in database, and so I want to create Model instances with that.

With django, I can create all the models instances, with MyMode

8条回答
  •  时光说笑
    2020-12-13 06:14

    Using create will cause one query per new item. If you want to reduce the number of INSERT queries, you'll need to use something else.

    I've had some success using the Bulk Insert snippet, even though the snippet is quite old. Perhaps there are some changes required to get it working again.

    http://djangosnippets.org/snippets/446/

提交回复
热议问题