Reputation: 59
I have a Django project, let's say "project1". Typical folder structure for applications is:
/project1/
/project1/
/settings.py
/urls.py
/wsgi.py
/manage.py
Now I want to move this settings.py file into local directory. Then how to use this setting.py file in our project (What should i write in manage.py and wsgi.py for use of settings.py file from new moved local directory location)
Upvotes: 0
Views: 1016
Reputation: 26
you have to set DJANGO_SETTINGS_MODULE
environment variable in django.wsgi
if you are using django with apache and mod_wsgi, have a look at https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
Upvotes: 0
Reputation: 36161
You need to add your local directory into your Python path (don't forget to put a __init__.py
file in the local folder) and adapt your DJANGO_SETTINGS_MODULE
environment variable, which is defined in the manage.py
:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yourproject.settings")
Be aware that it will take the first yourproject.settings
found in your Python Path, so it is not really a good idea to move it from the folder project. You can also use the --settings
option to specify the file to use.
python manage.py runserver --settings=yourproject.settings
Be careful, if you are doing this to avoid to commit the settings on a SVN/Git/Hg repository, it might be way easier to ignore the file in your CVS configuration, by ignoring settings.py
(and *.pyc
)
Upvotes: 2