Issue
I need to define an env var with a leading slash to be retrieved from within a python Django app running in a git bash shell on Windows 10.
The env var gets retrieved incorrectly from within the python session as shown below.
$ echo $STATIC_URL
$ export STATIC_URL=/static/
$ echo $STATIC_URL
/static/
$ python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ.get('STATIC_URL')
'C:/Program Files/Git/static/'
>>>
How can I set the STATIC_URL env var so that it will be retrieved correctly from within the python session? I need python to retrieve it as '/static/' just like bash does, not 'C:/Program Files/Git/static/'.
Solution
You can use dotenv for setting environment variables for your sessions.
Answered By - Yugandhar Chaudhari Answer Checked By - Marie Seifert (WPSolving Admin)