Search code examples
django

Is there an easy way to rename a Django project?


Is there an easy way to rename a Django project?

I tried to rename the folder, but it didn't work.


Solution

  • Renaming the project is actually easier than renaming an app. This question explains how to rename an app.

    To rename the project, you need to change the project name wherever it appears. grep -nir oldname . can help you find where it appears. In my case, I had to change the following places:

    1. Rename the oldprojectname directory to newprojectname

    2. manage.py: Change os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'oldprojectname.settings')

    3. newprojectname/wsgi.py: Change os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'oldprojectname.settings')

    4. newprojectname/settings.py: Change ROOT_URLCONF = 'oldprojectname.urls' and change WSGI_APPLICATION = 'oldprojectname.wsgi.application'

    5. newprojectname/urls.py: Change oldprojectname in a line I had added