Skip to content

Commit

Permalink
Cleanup multiple objectswq
Browse files Browse the repository at this point in the history
  • Loading branch information
shabda committed Apr 20, 2018
1 parent ceb14db commit 8c4402f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/multiple_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ We can use :code:`bulk_create` for creating multiple objects in one shot.

Here is an example.

.. code-block:: python
.. code-block:: ipython
>>> Category.objects.all().count()
2
>>> Category.objects.bulk_create([Category(name="Foods Items"), Category(name="Fruits"), Category(name="Vegetables")])
[<Category: Foods Items>, <Category: Fruits>, <Category: Vegetables>]
>>> 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
:code:`bulk_create` takes a list of unsaved objects.

0 comments on commit 8c4402f

Please sign in to comment.