[Answered ]-Environment variable not accessible in wsgi.py

1👍

I had to link the environment variables in gunicorn.service by setting them in a .env file like below.

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/myproj
EnvironmentFile=/home/ubuntu/myproj/.env
ExecStart=/home/ubuntu/myproj/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/myproj.sock myproj.wsgi:application

In my .env I set the variable.

DJANGO_ENV="PROD"

Leave a comment