I have a Django app named app1 with models and migrations files.
I renamed this app to app2 and I fixed all imports, urls etc...
I now have a probl
This is elequently answered in this blog post.
The bullet points are:
django_content_type table to refer to the application's app_label. django_migrations table and update the reference for each migration by setting the app field your new app label. /static or /templates folder. For example, you might have
./foo_app/templates/foo_app/index.html and it should be updated to ./bar_app/templates/bar_app/index.html.Renaming an app is always a tricky issue.
If you do the migration like a simple table renaming migration, at any moment the apps.get_model() for the old app cannot work because the app simply doesn't exist.
I found this answer. I know you are not using south, but I think it might work the same way, just skip the south steps.
Basically, you have to:
Dump the data, before rename, into a json file
Run the script in the answer to rename references in the json file from the app1 to app2
Rename app1 to app2 (all import references, settings.py, etc)
Run the migrations to create the tables for app2
Load the data from json file to the database
Drop the app1 tables
I hope this help.
I found a solution that's works
migrations.CreateModel.options, add db_table: 'app1_table_name'replaces = [('app1', 'migration_file_name')]. This will tell to Django that current migration (app2.migration_file_name) will replace the old file, this will prevenent django to execute migrations twice.