1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #36260 -- Made bulk_create() work with DB-generated primary keys.

Co-authored-by: Simon Charette <charette.s@gmail.com>
This commit is contained in:
Dmitry Shachnev
2025-03-16 20:50:45 +03:00
committed by Sarah Boyce
parent c75fbe8430
commit 77b4ecbd53
4 changed files with 21 additions and 6 deletions

View File

@@ -2427,10 +2427,11 @@ This has a number of caveats though:
* The model's ``save()`` method will not be called, and the ``pre_save`` and
``post_save`` signals will not be sent.
* It does not work with child models in a multi-table inheritance scenario.
* If the model's primary key is an :class:`~django.db.models.AutoField` and
``ignore_conflicts`` is False, the primary key attribute can only be
retrieved on certain databases (currently PostgreSQL, MariaDB, and SQLite
3.35+). On other databases, it will not be set.
* If the model's primary key is an :class:`~django.db.models.AutoField` or has
a :attr:`~django.db.models.Field.db_default` value, and ``ignore_conflicts``
is ``False``, the primary key attribute can only be retrieved on certain
databases (currently PostgreSQL, MariaDB, and SQLite 3.35+). On other
databases, it will not be set.
* It does not work with many-to-many relationships.
* It casts ``objs`` to a list, which fully evaluates ``objs`` if it's a
generator. The cast allows inspecting all objects so that any objects with a