Hi, 
I come across a problem when I want to deploy Django using Apache on 
Windows.

I separated some configurations into production.py and local.py, like 
database configurations.
And each files will read the actual setting data from a another file 
config.json.

I try to set the environment variables through the following files: 
 1. activate.bat  file of my virtual environment.
( This works only in local)

set "DJANGO_CONFIG=path\to\config.json"
set "DJANGO_SETTINGS_MODULE=myapp.settings.production"

 2. httpd.conf in Apache.
(env_module is enabled.)

LoadModule wsgi_module "path/to/mod_wsgi.cp37-win32.pyd"


WSGIScriptAlias / "path/to/wsgi.py"
WSGIPythonHome "path/to/virtualenv"
WSGIPythonPath "path/to/myproject"


SetEnv DJANGO_SETTINGS_MODULE "myapp.settings.production"
SetEnv DJANGO_CONFIG "path/to/config.json"


Alias /static "path/to/static-files"
<Directory "path/to/static-files">
     Require all granted
</Directory>


<Directory "path/to/myapp">
<Files wsgi.py>
     Require all granted
</Files>
</Directory>


The only way is to set the variables in wsgi.py, but this is not what I 
want.

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings.production')
os.environ.setdefault('DJANGO_CONFIG', 'path\to\config.json')

Please tell me if you need more information and thank you for helping.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ea0d1d61-f6b8-40f0-affe-61e78ddd41ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to