1👍
✅
In this case, to reference to django settings, all you need to do is chdir from your uwsgi.ini
to /proj/
directory. Now load your wsgi.py
file (you can keep it in your app/
subdirectory, it doesn’t contain any settings) from it using module
uWSGI setting and set DJANGO_SETTINGS_MODULE
to app.settings
, without anything else (it is enough to set it only in wsgi.py
file).
It should look like this (if you’ve moved your wsgi.py
back to app/
):
uwsgi.ini:
[uwsgi]
# ...
chdir = /proj/
module = app.wsgi
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
application = get_wsgi_application()
If you don’t want (for some reason) to keep your wsgi.py
file in app/
, your uwsgi.py
should have:
[uwsgi]
# ...
chdir = /proj/
module = web_config.prod.wsgi
But web_config
and prod
should be proper python modules (in python 2 they must have __init__.py
file inside). Content of wsgi.py
doesn’t change.
Source:stackexchange.com