@@ -130,7 +130,7 @@ Example: How do I use it with Django?
130
130
Given that I have a ``.env `` file at my repository root directory, here is a snippet of my ``settings.py ``.
131
131
132
132
I also recommend using `unipath <https://pypi.python.org/pypi/Unipath >`_
133
- and `dj-datatabase -url <https://pypi.python.org/pypi/dj-database-url/ >`_.
133
+ and `dj-database -url <https://pypi.python.org/pypi/dj-database-url/ >`_.
134
134
135
135
.. code-block :: python
136
136
@@ -182,9 +182,10 @@ Overriding config files with environment variables
182
182
183
183
Some times you may want to change a parameter value without having to edit the ``.ini `` or ``.env `` files.
184
184
185
- Since version 3.0, *decouple * respect the *unix way *. So environment variables have precedence over config files.
185
+ Since version 3.0, *decouple * respect the *unix way *.
186
+ Therefore environment variables have precedence over config files.
186
187
187
- To override a config parameter you can simply:
188
+ To override a config parameter you can simply do :
188
189
189
190
.. code-block :: console
190
191
@@ -258,7 +259,7 @@ Let's see some examples for the above mentioned cases:
258
259
259
260
>>> os.environ['ALLOWED_HOSTS'] = '.localhost, .herokuapp.com'
260
261
>>> config('ALLOWED_HOSTS', cast=lambda v: [s.strip() for s in v.split(',')])
261
- ['.localhost, ', '.herokuapp.com']
262
+ ['.localhost', '.herokuapp.com']
262
263
263
264
As you can see, `cast ` is very flexible. But the last example got a bit complex.
264
265
@@ -271,9 +272,10 @@ Let's improve the last example:
271
272
272
273
.. code-block :: pycon
273
274
275
+ >>> from decouple import Csv
274
276
>>> os.environ['ALLOWED_HOSTS'] = '.localhost, .herokuapp.com'
275
277
>>> config('ALLOWED_HOSTS', cast=Csv())
276
- ['.localhost, ', '.herokuapp.com']
278
+ ['.localhost', '.herokuapp.com']
277
279
278
280
You can also parametrize the *Csv Helper * to return other types of data.
279
281
@@ -285,9 +287,8 @@ You can also parametrize the *Csv Helper* to return other types of data.
285
287
286
288
>>> os.environ['COMPLEX_STRING'] = '%virtual_env%\t *important stuff*\t trailing spaces '
287
289
>>> csv = Csv(cast=lambda s: s.upper(), delimiter='\t', strip=' %*')
288
- >>> csv('%virtual_env%\t *important stuff*\t trailing spaces ' )
290
+ >>> csv(os.environ['COMPLEX_STRING'] )
289
291
['VIRTUAL_ENV', 'IMPORTANT STUFF', 'TRAILING SPACES']
290
- """
291
292
292
293
License
293
294
=======
0 commit comments