I need to separate the development and production settings of Django. I decided that if the USKOVTASK_PROD
variable USKOVTASK_PROD
set, the application should use the production settings. I read this article and tried to do it.
My snippets:
/etc/apache2/sites-enabled/uskovtask.conf:
<VirtualHost *:80> ServerName uskovtask.*.com ServerAlias uskovtask.*.com DocumentRoot /mnt/ebs/uskovtask Alias /static /mnt/ebs/uskovtask/static/ <Directory /mnt/ebs/uskovtask/static> Require all granted </Directory> #WSGIPythonPath /mnt/ebs/uskovtask WSGIDaemonProcess uskovtask.*.com python-path=/mnt/ebs/uskovtask:/usr/lib/python2.7/site-packages WSGIProcessGroup uskovtask.*.com WSGIScriptAlias / /mnt/ebs/uskovtask/uskovtask/wsgi.py SetEnv USKOVTASK_PROD 1 <Directory /mnt/ebs/uskovtask/uskovtask> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost>
wsgi.py:
import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "uskovtask.settings") from django.core.wsgi import get_wsgi_application _application = get_wsgi_application() def application(environ, start_response): if 'USKOVTASK_PROD' in environ: os.environ.setdefault('USKOVTASK_PROD', environ['USKOVTASK_PROD']) return _application(environ, start_response)
settings.py parameter:
import os if 'USKOVTASK_PROD' in os.environ: from settings_prod import * else: from settings_dev import *
But it always imports settings_dev parameters. Why?
source share