my_fruit.apple_plant.fruit_set.all().update(weird_plant = weird_plant) cheers.
On Mar 8, 7:22 pm, Sentenza wrote: > Hi, > > i'd like to hang some fruits belonging to an 'apple plant' also onto > another 'weird plant' -- for this i'm iterating over all fruits on the > apple plant, like this (i'm starting with one apple as my_fruit): > > for more_fruit in my_fruit.apple_plant.fruit_set.all(): > weird_plant.fruit_set.add(more_fruit) > > unfortunately i cannot add them in one go: > > weird_plant.fruit_set.add(my_fruit.apple_plant.fruit_set.all()) > > i also tried .add(list(..)) > > in raw sql this would be done as in: > UPDATE fruit SET weird_plant_id = %s WHERE apple_plant_id = %s, > [weird_plant.id, my_fruit.apple_plant_id] > > do i really have to loop over the items in _set? > > thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.