Why do we need set enviroment variables in wsgi.py and manage.py not in settings.py?

时间:2018-12-19 11:33:01

标签: python django environment-variables environment production-environment

I read tips for setting enviroment variables in python project and usually enviroment variables set in settings.py, but for Django project recommended to set environment valiables in wsgi.py and manage.py. What is advantages of this solution (instead of setting variables in settings.py)?

from dotenv import load_dotenv
# Load environment variables from .env file.
load_dotenv(verbose=True)

I use library python-dotenv and as lib description said

If you are using django you should add the above loader script at the top of wsgi.py and manage.py.

0 个答案:

没有答案