Django migration strategy for renaming a model and relationship fields

So when I tried this, it seems you can condense Step 3 – 7: class Migration(migrations.Migration): dependencies = [ (‘myapp’, ‘0001_initial’), ] operations = [ migrations.RenameModel(‘Foo’, ‘Bar’), migrations.RenameField(‘AnotherModel’, ‘foo’, ‘bar’), migrations.RenameField(‘YetAnotherModel’, ‘foo’, ‘bar’) ] You may get some errors if you don’t update the names where it’s imported e.g. admin.py and even older migration files … Read more

How to revert the last migration?

You can revert by migrating to the previous migration. For example, if your last two migrations are: 0010_previous_migration 0011_migration_to_revert Then you would do: ./manage.py migrate my_app 0010_previous_migration You don’t actually need to use the full migration name, the number is enough, i.e. ./manage.py migrate my_app 0010 You can then delete migration 0011_migration_to_revert. If you’re using … Read more