Skip to content

Commit

Permalink
Update docuemntation
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Jun 13, 2022
1 parent f12fc94 commit e1fa7cc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Added
`#355 <https://github.com/joke2k/django-environ/pull/355>`_.
- Added support for Django 4.0
`#376 <https://github.com/joke2k/django-environ/pull/376>`_.
- Added support for prefixed variables
`#362 <https://github.com/joke2k/django-environ/issues/362>`_.


Fixed
Expand Down
31 changes: 30 additions & 1 deletion docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,40 @@ It is possible to use of ``pathlib.Path`` objects when reading environment file
Overwriting existing environment values from env files
------------------------------------------------------

If you want variables set within your env files to take higher precidence than
If you want variables set within your env files to take higher precedence than
an existing set environment variable, use the ``overwrite=True`` argument of
``read_env``. For example:

.. code-block:: python
env = environ.Env()
env.read_env(BASE_DIR('.env'), overwrite=True)
Handling prefixes
=================

Sometimes it is desirable to be able to prefix all environment variables. For
example, if you are using Django, you may want to prefix all environment
variables with ``DJANGO_``. This can be done by setting the ``prefix``
to desired prefix. For example:

**.env file**:

.. code-block:: shell
# .env file contents
DJANGO_TEST="foo"
**settings.py file**:

.. code-block:: python
# settings.py file contents
import environ
env = environ.Env()
env.prefix = 'DJANGO_'
env.str('TEST') # foo

0 comments on commit e1fa7cc

Please sign in to comment.