I have found this code http://djangosnippets.org/snippets/2283/ but I think it doesn't work with manytomanyfields which use another model (keyword through) - I get an AttributeError when trying to merge.
Do you know any way to fix this or another method for merging objects ?
Edit: more details
I have 3 models: A, B, C
A has a manytomany field "m2mfield" pointing to C through B.
When I run the code from django snippets, it fails with the exception
'ManyRelatedManager' object has no attribute 'remove'
I think this has something to do with a comment in Django source (django.db.models.fields.related.py line 499) which says:
# If the ManyToMany relation has an intermediary model,
# the add and remove methods do not exist.
I think the code snippet I got doesn't make any difference between ManyToMany relations with and without intermediary model. That's why I'm looking for some way to fix that code or another way to achieve what I want (merging).