“os.environ” in django settings.py cannot get system environment variables with apache and wsgi

前端 未结 2 1769
名媛妹妹
名媛妹妹 2021-01-18 18:32

I set up the django setting.py like this:

import os
from django.core.exceptions import ImproperlyConfigured
def get_env_variable(var_name):
    try:
                 


        
2条回答
  •  自闭症患者
    2021-01-18 18:48

    You say "The environment variables were set in .bashrc." Presumably you mean your .bashrc. Which is pointless, because Apache is not running as you, it is running as the Apache user.

    As explained in the blog post referenced in the very question you link to, you need to set the environment variables in the Apache configuration file itself via the SetEnv directive.

提交回复
热议问题