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 99111f8 commit ebdd083Copy full SHA for ebdd083
model_clone/mixin.py
@@ -718,6 +718,8 @@ def __duplicate_linked_m2m_fields(self, duplicate):
718
:return: The duplicate instance objects from all the many-to-many fields duplicated.
719
"""
720
721
+ changed = False
722
+
723
for field in self._meta.many_to_many:
724
if all(
725
[
@@ -729,5 +731,9 @@ def __duplicate_linked_m2m_fields(self, duplicate):
729
731
source = getattr(self, field.attname)
730
732
destination = getattr(duplicate, field.attname)
733
destination.set(list(source.all()))
734
+ changed = True
735
736
+ if changed:
737
+ duplicate.save()
738
739
return duplicate
0 commit comments