Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Sep 7, 2021
1 parent e04667c commit 815078d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Added
- Added Elasticsearch7 to search scheme
`#314 <https://github.com/joke2k/django-environ/pull/314>`_.
- Provided ability to use ``bytes`` or ``str`` as a default value for ``Env.bytes()``.
- Added the ability to use env variable pointing to a ``.env`` file
`#242 <https://github.com/joke2k/django-environ/pull/242>`_

Fixed
+++++
Expand Down
23 changes: 23 additions & 0 deletions docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ It is possible to have multiple env files and select one using environment varia
Now ``ENV_PATH=other-env ./manage.py runserver`` uses ``other-env`` while ``./manage.py runserver`` uses ``.env``.


Using Path objects when reading env
===================================

Expand All @@ -154,3 +155,25 @@ It is possible to use of ``pathlib.Path`` objects when reading environment file
env.read_env(os.path.join(BASE_DIR, '.env'))
env.read_env(pathlib.Path(str(BASE_DIR)).joinpath('.env'))
env.read_env(pathlib.Path(str(BASE_DIR)) / '.env')
Using an environment variable to point to a .env file
=====================================================

Since v0.7.0 there is an ability to set an environment variable ``ENV_FILE``
to point to the .env file location. It can be convenient in a production
systems with a different .env file location.

The following example demonstrates the above:

.. code-block:: shell
# .secret file contents
SOME_VAR=3.14
.. code-block:: console
$ export ENV_FILE=$(pwd)/.secret
$ python -c 'from environ.environ import Env; Env.read_env(); print(Env.ENVIRON["SOME_VAR"])'
3.14

0 comments on commit 815078d

Please sign in to comment.