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
Fixes #1544. Add new parameter to Field called m2m_add which changes… #1545
Fixes #1544. Add new parameter to Field called m2m_add which changes… #1545
Conversation
…the behavior of Field.save such that it calls "add" instead of "set" for m2m fields.
…pport the args attribute for call_args).
Fixed test_fields.py to not use new python feature mock.Mock.call_args.args (which wasn't supported in python 3.7). Python 3.7 isn't supported on my computer (Apple M1 Mac) so wasn't able to test python 3.7 without running on GitHub. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting Brian.
I think it looks ok - I have a comment about the use of all() as this would have a performance impact and may not be required.
Removed the call to .all() as you recommended. It is unnecessary. Thanks! |
Thanks - free free to add your name to AUTHORS and I will merge. |
Done, with update for AUTHORS. Hit a conflict with AUTHORS which I think I've got resolved now. |
Thanks Matt! |
Thank you 👍 Now released in v3.1.0 |
Thank you Matt!
From: Matt Hegarty ***@***.***>
Date: Tuesday, February 21, 2023 at 11:26 AM
To: django-import-export/django-import-export ***@***.***>
Cc: Brian Nettleton ***@***.***>, Author ***@***.***>
Subject: Re: [django-import-export/django-import-export] Fixes #1544. Add new parameter to Field called m2m_add which changes… (PR #1545)
Thank you 👍 Now released in v3.1.0
—
Reply to this email directly, view it on GitHub<#1545 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEZ5IEJJ6MQBY4N4WL4NGG3WYUJHVANCNFSM6AAAAAAU6T7LGA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Add new parameter to Field called m2m_add which changes the behavior of Field.save such that it calls "add" instead of "set" for m2m fields.
Problem
Enables creating a resource which adds values to a ManyToMany field instead of overwriting existing values.
Solution
When m2m_add is True call the add method instead of the set method on an m2m field. Exclude already existing values in the m2m field so that multiple exports and re-imports don't keep adding the same fields repeatedly.
Acceptance Criteria
Have you written tests? Yes
Have you included screenshots of your changes if applicable? N/A
Did you document your changes? Yes. Added documentation in the docstring for the new m2m_add parameter.