diff options
| author | Johanan Oppong Amoateng <johananoppongamoateng2001@gmail.com> | 2025-12-12 23:17:38 +0000 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-12-19 14:01:37 -0500 |
| commit | 33a0a6f033b9243e0cc98e76bd494de73cf144eb (patch) | |
| tree | 3883721f41d95d2e332a6988a99d494f55ba1f62 /django | |
| parent | 948f1bf5a1c1c93ee9c6f4baa2fd990e31361f81 (diff) | |
Fixed #36791 -- Made MigrationAutodetector recreate through table when m2m target model changes.
Co-Authored-By: Jacob Walls <38668450+jacobtylerwalls@users.noreply.github.com>
Co-Authored-By: Clifford Gama <cliffygamy@gmail.com>
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/autodetector.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index 7cc22c0637..0c2e215fcd 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -1339,7 +1339,10 @@ class MigrationAutodetector: if old_field_dec != new_field_dec and old_field_name == field_name: both_m2m = old_field.many_to_many and new_field.many_to_many neither_m2m = not old_field.many_to_many and not new_field.many_to_many - if both_m2m or neither_m2m: + target_changed = ( + both_m2m and new_field_dec[2]["to"] != old_field_dec[2]["to"] + ) + if (both_m2m or neither_m2m) and not target_changed: # Either both fields are m2m or neither is preserve_default = True if ( |
