Opened 10 months ago

Last modified 4 weeks ago

#23034 assigned New feature

Add migrations support for adding ManyToMany "through" model

Reported by: lorinkoz@… Owned by: knbk
Component: Migrations Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Adding a "through" model on a ManyToMany field make "makemigrations" fail with an explicit error stating that it is not possible. I have worked it around by renaming the field, creating the migration (so as to make Django believe it's a new field) and then renaming the field back to the original name and creating another migration (which is correctly acknowledged by Django as a simple "renaming"). I understand the implications of adding a through model from the migrations perspective, but maybe a more friendly output could be achieved. Is it even possible to create some sort of interaction, like when you create a field with not null and no default value, so as to ask the user if they want to destroy/create a new field??

Change History (7)

comment:1 Changed 9 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Migrations fail with modified ManyToMany "through" model to Add migrations support for adding ManyToMany "through" model
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to New feature

As Andrew noted in #22476, "as the error message says, you cannot alter an M2M without a through model into one with a through model, at least not in the current system." I'm not sure how feasible it will be to add support for thits, but tentatively accepting.

comment:2 Changed 8 months ago by andrewgodwin

  • Triage Stage changed from Accepted to Someday/Maybe

Triaging this to "someday/maybe". It would be nice, but it's a complex thing to add.

comment:3 Changed 7 weeks ago by knbk

  • Owner changed from nobody to knbk
  • Status changed from new to assigned
  • Triage Stage changed from Someday/Maybe to Accepted
  • Version changed from 1.7-rc-1 to master

comment:5 Changed 6 weeks ago by knbk

  • Patch needs improvement set

comment:6 Changed 6 weeks ago by knbk

  • Patch needs improvement unset

comment:7 Changed 4 weeks ago by timgraham

  • Patch needs improvement set

Markus reviewed the PR.

Note: See TracTickets for help on using tickets.
Back to Top