How does one update - in bulk - a many to many field in the queryset of a Django data model?
For instance, I have a data model called Photo
, and another called PhotoStream
. In Photo
, I have which_stream = models.ManyToManyField(PhotoStream)
.
I extracted a queryset of Photos
called childhood_photos
, and I need to add a new PhotoStream
object in the many-to-many fields of all objects within this queryset. Let's call this PhotoStream object for_classmates
.
I try childhood_photos.update(which_stream.add(for_classmates))
, but it gives me an error: global name 'which_stream' is not defined.
How can I do this operation?