First, let me say thanks to OP for clarifying that the value must be list for such use.
I was not able to get the approach described in the accepted answer to work in my application, which used a slightly different approach, adding M2M relationships to non-owning objects.
I had to do this, which admittedly seems a bit hacky:
setattr(target_object, f'{key}.all()', [source_object.__getattribute__(key), ])
Note the use of f'{key}.all()'
Without this, I get an error when I try to access ManyToManyField from the wrong side, which suggests using the field.set () method.
Probably not optimal, but hopefully useful for the next guy.
source share