-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
Enable diffing m2m fields #932
Conversation
0ad5b78
to
4efc956
Compare
4efc956
to
abeedda
Compare
abeedda
to
7bd18a1
Compare
I wonder if perhaps the PR title is not quite right, since this seems to be doing more than allowing for a diff. |
@thijskramer It looks like some tests failed in the GH Action, could you look into that? This feature would be really helpful for me! |
I'll take a look in the upcoming days!
…On Thu, 17 Mar 2022 at 14:32, Thomas Lazarus ***@***.***> wrote:
@thijskramer <https://github.com/thijskramer> It looks like some tests
failed in the GH Action, could you look into that? This feature would be
really helpful for me!
—
Reply to this email directly, view it on GitHub
<#932 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJXH42JAPEE5VPM557ZSA3VAMX5LANCNFSM5KN4257A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
c3444e8
to
4b7538d
Compare
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.
I've looked through this and it looks good to me! Hopefully it can get merged in soon!!
I have to fix a few tests before it can be merged, but I’m a bit short on
time so I’d welcome any help!
…On Fri, 25 Mar 2022 at 15:17, Thomas Lazarus ***@***.***> wrote:
***@***.**** approved this pull request.
I've looked through this and it looks good to me! Hopefully it can get
merged in soon!!
—
Reply to this email directly, view it on GitHub
<#932 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJXH44NW6P5MR22DAZEQP3VBXDFTANCNFSM5KN4257A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
`django-simple-history` doesn't currently track changes to many-to-many relationships - which was the main point of this commit (i.e. to track the changes to `own_permissions`) - but once jazzband/django-simple-history#399 is resolved (likely through jazzband/django-simple-history#932), it will.
I fixed your tests on thijskramer#20 |
One more to go thijskramer#21 to resolve conflicts with master |
I think it's cleaner to rebase this branch onto |
Working prototype with tests - Custom through models may not work correctly - Currently storing IDs for FKs, probably needs replacing Now using model instances instead of IDs when possible flake8 fixes Delete dead code, comments, and change to bulk create Clean up, add m2m support to diff_against Add basic tests for several m2m fields on one model Formatting fixes from Black Housekeeping, fixing Python 2.7, removing Python 3.4 - Py3.4 removed as coverage no longer supports it, could be pinned instead, but I went with this. remove python2 thing
Indeed I tried that but with my own branch so it conflicts with your branch now |
I've rebased my branch! |
I added inheritance support with thijskramer#22 |
Sorry about a comment that isn't immediately relevant, I just wanted to say that I really want the feature and I'm very happy to see the current activity. Thank you @thijskramer and @legau for your work! |
hey all, any reason this couldn't be merged? m2m field tracking would be a huge plus! |
Codecov Report
@@ Coverage Diff @@
## master #932 +/- ##
==========================================
- Coverage 97.65% 97.11% -0.54%
==========================================
Files 23 23
Lines 1149 1215 +66
Branches 222 237 +15
==========================================
+ Hits 1122 1180 +58
- Misses 12 17 +5
- Partials 15 18 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@thijskramer @valberg @legau @johanneswilm thanks for all the work and merging this in 🙌 |
Has this been tested in the django admin? For me with the multi-picker widget it does not reflect the state correctly for historical records. It still just renders the current state. |
@chrisbarber Yeah, it's a known bug; see #1063 |
At first @avalanchy did the initial work. After that https://github.com/bmedx made an excellent PR based on his work which wasn't completed, so I tried to make it work and created a PR myself, based on edx#1 and rebased on the current master.
Description
This PR enables tracking history of m2m relations. It works in my specific situation, however I would be happy to hear if there are any situations I haven't looked at, I should cover or simply could be improved.
Related Issue
#399 - Track history of M2M fields
Motivation and Context
A few days ago I received the question "how can I see who has removed an article from this category?" I immediately dove into the history I had enabled, but I quickly discovered that m2m relations weren't tracked. I started googling for solutions and stumbled upon the Pull Request @bmedx made for #399.
I installed his fork and after some minor tweaks and a rebase, I made it work for my situation.
It tracks each m2m change in a separate m2m_history model, so that you won't need a reference to the actual referenced model.
How Has This Been Tested?
Tests have been included, however I'm unsure if they are enough to cover all use cases.
Type of change
Checklist:
pre-commit run
command to format and lint.AUTHORS.rst
CHANGES.rst