MCPcopy
hub / github.com/django/django / _prepare_for_bulk_create

Method _prepare_for_bulk_create

django/db/models/query.py:724–738  ·  view source on GitHub ↗
(self, objs)

Source from the content-addressed store, hash-verified

722 acreate.alters_data = True
723
724 def _prepare_for_bulk_create(self, objs):
725 objs_with_pk, objs_without_pk = [], []
726 for obj in objs:
727 if isinstance(obj.pk, DatabaseDefault):
728 objs_without_pk.append(obj)
729 elif obj._is_pk_set():
730 objs_with_pk.append(obj)
731 else:
732 obj.pk = obj._meta.pk.get_pk_value_on_save(obj)
733 if obj._is_pk_set():
734 objs_with_pk.append(obj)
735 else:
736 objs_without_pk.append(obj)
737 obj._prepare_related_fields_for_save(operation_name="bulk_create")
738 return objs_with_pk, objs_without_pk
739
740 def _check_bulk_create_options(
741 self, ignore_conflicts, update_conflicts, update_fields, unique_fields

Callers 1

bulk_createMethod · 0.95

Calls 4

_is_pk_setMethod · 0.80
appendMethod · 0.45
get_pk_value_on_saveMethod · 0.45

Tested by

no test coverage detected