2

I have a Model file which has a change which isn't being picked up by DJango makemigrations.

I created a manual migration following this answer, but if we run makemigrations afterwards Django creates a new auto migration reverting our manual changes.

Is there a way to manually make a migration and tell DJango to ignore relevant parts of the code when generating future migrations?

Jethro
  • 3,029
  • 3
  • 27
  • 56
  • Note I'm working on a bug testcase for the apparent bug causing django not to pick up the change in the first place - this Question is under the assumption that it doesn't get fixed. – Jethro Sep 23 '20 at 07:15
  • 1
    "*but if we run makemigrations afterwards Django creates a new auto migration reverting our manual changes."* Can you add a minimal reproducable example? – JPG Sep 23 '20 at 07:35

1 Answers1

1

After making changes to the models and creating a custom migration for them e.g. using RunPython or RunSQL you can use the state_operations argument to reflect the changed models' state in your custom Python or SQL operations.

skittr
  • 26
  • 1