Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] m2m fields are cloned even if _clone_m2m_fields is empty #701

Closed
3 tasks done
benedikt-bartscher opened this issue Nov 16, 2022 · 2 comments · Fixed by #702
Closed
3 tasks done

[BUG] m2m fields are cloned even if _clone_m2m_fields is empty #701

benedikt-bartscher opened this issue Nov 16, 2022 · 2 comments · Fixed by #702
Labels
bug Something isn't working

Comments

@benedikt-bartscher
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

When setting _clone_m2m_fields = [] for a clone model m2m fields are cloned anyway.

To Reproduce

Create a Model with CloneMixin and set
_clone_m2m_fields = []

What OS are you seeing the problem on?

No response

Expected behavior?

m2m fields are not cloned

Relevant log output

No response

Anything else?

It would be nice to set different behaviours for m2m fields like:

  • SET_NULL (just clears m2m fields)
  • CLONE (clone referenced objects, current behaviour)
  • LINK (create m2m relations with existing objects new.m2mfield.set(old.m2mfield.all())

Code of Conduct

  • I agree to follow this project's Code of Conduct
@benedikt-bartscher benedikt-bartscher added the bug Something isn't working label Nov 16, 2022
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1 jackton1 linked a pull request Nov 17, 2022 that will close this issue
@jackton1
Copy link
Member

jackton1 commented Nov 17, 2022

@benedikt-bartscher To clarify see the test in the linked PR as the default _clone_m2m_fields = []

SET_NULL (just clears m2m fields) - This is the default if no explicit _clone_m2m_fields is used.
CLONE (clone referenced objects, current behaviour) - This happens when _clone_m2m_fields is set.
LINK (create m2m relations with existing objects new.m2mfield.set(old.m2mfield.all()) - Would need to support this as the old objects are also duplicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants