﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33649	bulk_create() with ignore_conflicts=True and ForeignKey fails	Markus Friedrich	nobody	"Creating both objects of a many-to-one relation using bulk_create together with ignore_conflicts=True fails since Django >=3.2!

To enable many-to-one relations in bulk_create the ""to_field"" of the ForeignKey is defined via a UUIDField with a uuid.UUID4 default value.

Without the ignore_conflicts=True option of bulk_create it works well in all Django versions.
But if ignore_conflicts=True is needed since some of the objects using in the bulk_create may already be saved to the DB then it works only for Django < 3.2.
With Django >= 3.2 (including 4.0.4) it fails with:
`ValueError: bulk_create() prohibited to prevent data loss due to unsaved related object 'reporter'`.

Find attached a test app which reproduces this issue with a minimal example, see
mysite/polls/models.py and mysite/polls/tests.py"	Bug	closed	Database layer (models, ORM)	3.2	Normal	invalid	bulk_create ForeignKey ignore_conflicts	Hannes Ljungberg	Unreviewed	0	0	0	0	0	0
