Message info
 
To: From:Django Subject:[Django] #18285: bulk_create and ManyToMany relationships: the relationship is actually not made Date:Mon, 07 May 2012 20:45:44 -0000
 

#18285: bulk_create and ManyToMany relationships: the relationship is actually not
made
-------------------------------------+-------------------------------------
Reporter: Michael PALUMBO | Owner: nobody
<michael.palumbo87@> | Status: new
Type: Bug | Version: 1.4
Component: Database layer | Keywords: bulk_create,
(models, ORM) | relationship
Severity: Normal | Has patch: 0
Triage Stage: Unreviewed | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
bulk_create with relationships does not work: i.e. the relationship is not
made.

For example:
{{{
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

--
Ticket URL: <https://code.djangoproject.com/ticket/18285>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to django-updates+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.