bulk_create and ManyToMany relationships: the relationship is actually not made
|Reported by:||Michael PALUMBO <michael.palumbo87@…>||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 4 years ago by akaariai
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:2 Changed 4 years ago by moritzs
- Component changed from Database layer (models, ORM) to Documentation
- Type changed from Bug to Cleanup/optimization
comment:3 Changed 2 years ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from new to closed