Can you stop Django automatically reverting a manual Migration?

281 views Asked by At

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?

1

There are 1 answers

0
skittr On BEST ANSWER

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.