You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This block is a duplicate functionality of the functions __duplicate_m2o_fields and __duplicate_o2m_fields.
And does not use _clone_m2o_or_o2m_fields.
As a result, additional copies of records appear.
I propose a solution - remove this block:
if (f.many_to_one or f.one_to_many) and instance._state.db != using:
sub_instance = getattr(instance, f.name, None) or f.get_default()
if sub_instance is not None:
sub_instance = CloneMixin._create_copy_of_instance(
sub_instance,
force=True,
sub_clone=True,
using=using,
)
sub_instance.save(using=using)
value = sub_instance.pk
To Reproduce
class Item(Model, CloneMixin):
pass
class ModelName(Model, CloneMixin):
items = ForeignKey(Item)
_clone_m2o_or_o2m_fields = ['item']
ModelName.objects.using('db-id-1').get(pk=1).make_clone(using=DEFAULT_DB_ALIAS)
What OS are you seeing the problem on?
No response
Expected behavior?
Don't create additional copies of records
Relevant log output
No response
Anything else?
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Does this issue exist in the latest version?
Describe the bug?
This block is a duplicate functionality of the functions
__duplicate_m2o_fields
and__duplicate_o2m_fields
.And does not use
_clone_m2o_or_o2m_fields
.As a result, additional copies of records appear.
I propose a solution - remove this block:
To Reproduce
What OS are you seeing the problem on?
No response
Expected behavior?
Don't create additional copies of records
Relevant log output
No response
Anything else?
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: