Question about batch save objects in Django

前端 未结 5 978
一向
一向 2020-12-14 15:47

I haven\'t seen any thing on this topic in Django\'s online documents.

I am trying to save a list of objects to database, but what I can do is loop through the list

5条回答
  •  余生分开走
    2020-12-14 16:10

    As of Django 1.4, there exists a bulk_create() method on the QuerySet object, which allows for inserting a list of objects in a single query. For more info, see:

    • Django documentation for bulk_create
    • Django 1.4 release notes
    • The ticket that implemented this feature

提交回复
热议问题