Skip to content

Added support for SynchronizedField on ManyToManyFields#891

Open
tognee wants to merge 2 commits intowagtail:mainfrom
infofactory:feat/sync-many-to-many
Open

Added support for SynchronizedField on ManyToManyFields#891
tognee wants to merge 2 commits intowagtail:mainfrom
infofactory:feat/sync-many-to-many

Conversation

@tognee
Copy link
Copy Markdown
Contributor

@tognee tognee commented Nov 26, 2025

This PR lets users set a ManyToManyField as a SynchronizedField without recieving the error:

Direct assignment to the forward side of a many-to-many set is prohibited. Use model_name.set() instead.

This does not solve the issue of whether a ManyToMany field should be translatable or syncronized, but gives the option for the user to syncronize it without errors.

This PR adds:

  • the code changes to handle many to many fields
  • a snippet model to test ManyToMany fields (with its migration)
  • 3 unit tests to check if the SynchronizedField is respected correctly for ManyToMany

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.04%. Comparing base (8ba01e7) to head (fe388cf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #891      +/-   ##
==========================================
+ Coverage   93.02%   93.04%   +0.01%     
==========================================
  Files          47       47              
  Lines        4245     4257      +12     
  Branches      551      552       +1     
==========================================
+ Hits         3949     3961      +12     
  Misses        177      177              
  Partials      119      119              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tognee
Copy link
Copy Markdown
Contributor Author

tognee commented Nov 28, 2025

I've seen that bitnami moved all free postgresql images to bitnamilegacy. I changed it just to test the checks, but I think it could it be replaced with the official docker postgresql image

Copy link
Copy Markdown
Contributor

@Marvinrose Marvinrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codecov report flags one missing line in test/models.py, worth checking which line isn't covered and adding a test case for it.
The bitnamilegacy image change in test.yml makes sense as a short-term fix, but as you noted it might be worth replacing with the official postgres Docker image for long-term stability.

@tognee tognee force-pushed the feat/sync-many-to-many branch 2 times, most recently from 2d94e37 to b0d9633 Compare April 5, 2026 06:45
@tognee tognee force-pushed the feat/sync-many-to-many branch from b0d9633 to fe388cf Compare April 5, 2026 06:51
@tognee
Copy link
Copy Markdown
Contributor Author

tognee commented Apr 7, 2026

@Marvinrose I've aligned to main and added a test for the __str__ function in the test model
Now Codecov seems happy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants