$ pip install django-flexisettings
No need to declare flexisettings in INSTALLED_APPS.
Edit manage.py, modify the value of DJANGO_SETTINGS_MODULE to point at flexisettings.settings and add FLEXI_WRAPPED_MODULE to point at your project’s settings:
[...]
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "flexisettings.settings")
os.environ.setdefault("FLEXI_WRAPPED_MODULE", "myproject.settings")
[...]
Edit myproject/wsgi.py, modify the value of DJANGO_SETTINGS_MODULE to point at flexisettings.settings and add FLEXI_WRAPPED_MODULE to point at your project’s settings:
[...]
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "flexisettings.settings")
os.environ.setdefault("FLEXI_WRAPPED_MODULE", "myproject.settings")
[...]
Following django’s recommandations on how to use gunicorn, the project will run in WSGI mode.
First edit the myproject/wsgi.py file as shown in the WSGI application paragraph.
$ cd /path/to/myproject
$ /path/to/venv/bin/python gunicorn --workers=42 myproject.wsgi:application
The configuration file for gunicorn should be saved as /etc/gunicorn.d/myproject and contain:
CONFIG = {
'python': '/path/to/venv/bin/python',
'working_dir': '/path/to/myproject',
'user': 'www-data',
'group': 'www-data',
'args': (
'myproject.wsgi:application',
),
}
For more information on gunicorn configuration, read the docs.