Djanogo Console does not use environment variables set in PyCharm
Answered
Hi,
if I use the Django Console. It does not use custom environment variables set in PyCharm
How to reproduce:
- Create new Django Project with new venv
- Add custom Enviroment variable FOO = BAR
- Open Django Console and write
os.environ['FOO']
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\Python37\lib\os.py", line 678, in __getitem__
raise KeyError(key) from None
KeyError: 'FOO' - Verify to get HOMEDRIVE
os.environ['HOMEDRIVE']
'C:'

------
PyCharm 2019.3.3 (Professional Edition)
Build #PY-193.6494.30, built on February 6, 2020
Licensed to
Subscription is active until March 24, 2020
Runtime version: 11.0.5+10-b520.38 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 980M
Cores: 4
Registry:
Non-Bundled Plugins: com.tabnine.TabNine
Please sign in to leave a comment.
Hi,
Adding environment variables to the run configuration won't affect your Django Console.
You should do it in Django Console settings File | Settings | Build, Execution, Deployment | Console | Django Console