We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 335a9c5 commit e76385dCopy full SHA for e76385d
model_clone/mixin.py
@@ -719,6 +719,8 @@ def __duplicate_linked_m2m_fields(self, duplicate):
719
:return: The duplicate instance objects from all the many-to-many fields duplicated.
720
"""
721
722
+ changed = False
723
+
724
for field in self._meta.many_to_many:
725
if all(
726
[
@@ -730,5 +732,9 @@ def __duplicate_linked_m2m_fields(self, duplicate):
730
732
source = getattr(self, field.attname)
731
733
destination = getattr(duplicate, field.attname)
734
destination.set(list(source.all()))
735
+ changed = True
736
737
+ if changed:
738
+ duplicate.save()
739
740
return duplicate
0 commit comments