3š
Main project name is used as a base for your namespace.
By default, you will have in settings.py line: āROOT_URLCONF = āsomething.urls'ā.
To change a project name, you need to change every single import that is referring to it.
Of course you can always use modules without āsomethingā prefix, then you must ensure that there will be no name/namespace conflict between modules. Iām using this option, because I can have same code in a few copies without additional hassle.
1š
Late to this party, but for future reference this may help somebody. Iāve just had to change a project name because it clashed with the name of a third-part app. Itās easier to change a project name than an app name! (Django 1.11)
Folder structure
project/
manage.py
project/
settings.py
urls.py
wsgi.py
venv/
- If using a virtual environment in
venv
, generate an up to daterequirements.txt
withpip freeze
- Rename both
project/
folders tonewproject
- Change
project
tonewproject
in the python files:
manage.py, look for DJANGO_SETTINGS_MODULE
settings.py, look for DJANGO_SETTINGS_MODULE and WSGI_APPLICATION, and a comment. You can and should leave the name of the database and the database user unchanged, assuming you want to keep the data.
urls.py, in a triple-quoted string
wsgi.py, DJANGO_SETTINGS_MODULE plus a comment
-
If using a virtual environment, you need to recreate it. I renamed
venv
toold.venv
, thenvirtualenv-3 venv
, then usepip install
and the requirements file you generated at 1. Trashold.venv
when sure the new one is working AOK. -
/path/to/project
will also feature in system config files such as/etc/nginx
and a.service
file for gunicorn, which will need changing to/path/to/newproject
. -
Restart the server and test. Should be working.
Now you can add an app called project
to your INSTALLED_APPS!
I now know that itās a good idea to call in-house Django projects ${my_org_name}_something
, or similar, so they wonāt clash with third-party apps.
- Extend django rest framework to allow inheriting context in nested serializers
- Jython + Django not ready for production?
- Place to set SQLite PRAGMA option in Django project
- Django 1.7 makemigrations freezing/hanging