Easy way to rename a django project

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


I think the best solution here is to simply open your settings.py, urls.py, views.py and any other file that might rely on your project's name and then use the find&replace function in your text editor.

Or, if you haven't done much work yet, start a new project with django-admin.py and copy/paste.

Tags:

Django