django rename app
Before renaming
Always migrate databases before changing the app name.
manage.py makemigrations
when you see the following message then it is safe to proceed with renaming the app.
No changes detected
Fixed table names
For this case it is assumed the table names are fixed in models.py
Rename and Loose migration
- remove migrations from db:
manage.py migrate --fake old_app_name zero
- remove migration files from app
find old_app_name -path "*/migrations/*.py" \
-not -name "__init__.py" \
-delete
find old_app_name -path "*/migrations/*.pyc" \
-delete
-
rename folder and update all references to app. Take special note of updating '''views.py''', '''urls.py''', and '''settings.py'''
-
Edit the database table '''django_content_type'''. For this step you need to rename the old app name with the new app name in the column 'app_label'
-
reset migrations
manage.py makemigrations
manage.py migrate --fake-initial
manage.py showmigrations
Reference
Rename Steps
Show archive.org snapshot
django reset migrations