I have changed the name of an app in Django by renaming its folder, imports and all its references (templates/indexes). But now I get this error when I try to run
python manage.py runserver
Error: Could not import settings 'nameofmynewapp.settings' (Is it on sys.path?): No module named settings
Follow these steps to change an app's name in Django:
urls.py, 'manage.py' , and
django_content_typewith the following command:
UPDATE django_content_type SET app_label='<NewAppName>' WHERE app_label='<OldAppName>'
ALTER TABLE <oldAppName>_modelName RENAME TO <newAppName>_modelName. For mysql too I think it is the same (as mentioned by @null_radix)
django_migrationstable to avoid having your previous migrations re-run:
UPDATE django_migrations SET app='<NewAppName>' WHERE app='<OldAppName>'
models.py's Meta Class has
app_namelisted, make sure to rename that too (mentioned by @will).
templatesfolders inside your app, you'll also need to rename those. For example, rename
models, you'll need to change
django_content_type.name. For postgreSQL use
UPDATE django_content_type SET name='<newModelName>' where name='<oldModelName>' AND app_label='<OldAppName>'