[Solved]-How does a .env file relate to Python / Django?

11👍

We can only guess because we don’t have access to your actual environment.

The .env file may be a container manager thing or something from libraries like python-decouple – for practical effects the .env will be used to populate the environment variables when the container “boots” or will be used to fill instance settings.

There is a common pattern made popular by the Twelve-Factor app: the item III is “Store config in the environment”. Then in the settings.py file you use the KEY = os.environ.get('KEY', 'defaul_value'). The idea is to separate instance settings from project settings from code.

Leave a comment