Hi,

I am trying to add items to a ManyToMany relationship, but I would like to 
make the operation use a particular database connection, like one might do 
when calling save() on a model instance. However, looking at the source for 
ManyToMany.add(), the function defaults to checking the router's for_write 
connection.

class B(models.Model):
...

class A(models.Model):
b = models.ManyToManyField(B)
...

ideally, I would like to modify the many to many field as follows...
a = A(id=0)
for b in B.objects.all():
    a.b.add(b, using="aconnection")

but this does not work. As far Is there an alternative way to insert an 
object into the ManyToMany relationship(where a db alias can be specified) 
besides add?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a49409db-5b9a-48cd-818f-6645caa184e9n%40googlegroups.com.

Reply via email to