Installation and configuration¶
Installation¶
$ pip install django-flexisettings
No need to declare flexisettings in INSTALLED_APPS
.
Configuration¶
Development¶
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")
[...]
WSGI application¶
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")
[...]
Gunicorn¶
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.
Command line¶
$ cd /path/to/myproject
$ /path/to/venv/bin/python gunicorn --workers=42 myproject.wsgi:application
Debian¶
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',
),
}
- Extra options that could be useful in the
args
tuple: '--bind=ip:port'
: set which ip and port the process whould bind to'--workers=#'
: set the number of workers to spawn
For more information on gunicorn configuration, read the docs.