I am trying to set a new structure for settings.py in my django app. ( Django 1.7b4 - python 3.3.2 )
- manage.py
- mainapp
-- wsgi.py
-- urls.py
-- settings
--- __init__.py
--- common.py
--- development.py
--- production.py
I have changed manage.py and wsgi.py as
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mainapp.settings.common")
But i got an 'Empty Secret Key Error'. Because django still tries to find settings inside mainapp.settings ( which is default ) and looks inside the empty init.py file...
In my mac os terminal i checked and changed DJANGO_SETTINGS_MODULE environment variable... But nothing changes. Django always search in default location.
You need to set the DJANGO_SETTINGS_MODULE environment variable for your web server. In the case of apache this takes the form:
SetEnv DJANGO_SETTINGS_MODULE mainapp.settings.common
I've added this in my virtualhost configuration and it works great
If you are using the development server (runserver) you can specify a custom settings module:
python manage.py runserver --settings=mainapp.settings.common
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With