﻿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
27026	Objects not fully configured after bulk_create.	Sjoerd Job Postmus	nobody	"Objects not fully configured after bulk_create.

When running `bulk_create` on multiple objects, the primary key now gets set (if using postgresql), but the `_state` field does not get updated.

This makes some features of the ORM work with the newly ""id""-ed objects, but others not.

In particular, the following case fails:

{{{#!python
#models.py
class Country(models.Model):
    name = models.CharField(max_length=255)
    iso_two_letter = models.CharField(max_length=2)


class Union(models.Model):
    name = models.CharField(max_length=255)
    countries = models.ManyToManyField(Country)


#tests.py
    @skipUnlessDBFeature('can_return_ids_from_bulk_insert')
    def test_set_pk_and_allow_creating_related(self):
        union_eu = Union.objects.create(name='EU')
        country_nl = Country(name='Netherlands', iso_two_letter='NL')
        with self.assertNumQueries(1):
            Country.objects.bulk_create([country_nl])
        union_eu.countries.add(country_nl)
}}}"	Bug	closed	Database layer (models, ORM)	1.10	Release blocker	fixed	bulk_create, postgresql, ManyToManyField		Accepted	0	0	0	0	0	0
