Skip to content

Commit

Permalink
Merge pull request #223 from jazzband/docs/explain-dotenv-files
Browse files Browse the repository at this point in the history
Explain how to read .env files
  • Loading branch information
bittner committed Dec 10, 2018
2 parents 3c8590a + e7d63e0 commit f38e07b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,37 @@ Simply import it from ``configurations.management`` instead:
call_command('dumpdata', exclude=['contenttypes', 'auth'])
Read .env file
--------------

Configurations can read values for environment variables out of an ``.env``
file, and push them into the application's process environment. Simply set
the ``DOTENV`` setting to the appropriate file name:

.. code-block:: python
# mysite/settings.py
from os.path import dirname, join
from configurations import Configuration
BASE_DIR = dirname(dirname(__file__))
class Dev(Configuration):
DOTENV = join(BASE_PATH, '.env')
SECRET_KEY = values.SecretValue()
An ``.env`` file is an ``.ini``-style file. It must contain a list of
``KEY=value`` pairs, just like Shell environment variables:

.. code-block:: ini
# .env
DJANGO_DEBUG=False
DJANGO_SECRET_KEY=1q2w3e4r5t6z7u8i9o0(%&)$§"!pqaycz
Envdir
------

Expand Down

0 comments on commit f38e07b

Please sign in to comment.