Answers for "django create multiple objects at once"

1

django createmany

>>> Category.objects.all().count()
2
>>> Category.objects.bulk_create(
    [Category(name="God"),
     Category(name="Demi God"),
     Category(name="Mortal")]
)
[<Category: God>, <Category: Demi God>, <Category: Mortal>]
>>> Category.objects.all().count()
5
Posted by: Guest on March-11-2020

Code answers related to "django create multiple objects at once"

Python Answers by Framework

Browse Popular Code Answers by Language