bulk_create and ManyToMany relationships: the relationship is actually not made
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
bulk_create with relationships does not work: i.e. the relationship is not made.
class Company(models.Model): url = models.URLField(unique=True) class Website(models.Model): url = models.URLField(unique=True) companies = models.ManyToManyField(Company, null=True, blank=True) list_companies = [Company(url='...'), Company(url='...')] w.companies.bulk_create(list_companies) -> [< Company: Company object>, < Company: Company object>] #The 2 Company objects are created w.companies.all() ->  # But the relationship is broken
The 2 companies are created but I cannot access to them through the many-to-many relationship.
I looked at the database and yes I can find the 2 companies in the company table but no rows in the website_company table.
Discussed on django developers group: https://groups.google.com/forum/?fromgroups#!topic/django-developers/VNhDD2Golws
Change History (4)
comment:1 Changed 5 years ago by
|Triage Stage:||Unreviewed → Accepted|
comment:2 Changed 5 years ago by
|Component:||Database layer (models, ORM) → Documentation|
|Type:||Bug → Cleanup/optimization|