PyCharm Run/Debug configuration uses incorrect DJANGO_SETTINGS_MODULE
In my Django Run configuration, I try to make PyCharm use a specific ENV variable (DJANGO_SETTINGS_MODULE in this case), but it reverts back to using default values (system environment variables).
I do not understand where PyCharm picks up the "system environment variables" from (I have different settings in my .env file AND in the shell environment)
I also do not understand why PyCharm will not let me override the system environment variables with my defined one. I add them in the "Environment variables" part of the Run/Debug config - but they are not stored or used. (reverts back to the original setting).
I see that the DJANGO_SETTINGS_MODULE is the only one marked in blue in the "systems environment variables" list. What does this mean?
Any hints on how to figure this out would be welcome.
I use PyCharm 2019.1 and a Docker-compose remote interpreter.
Please sign in to leave a comment.
Hi,
>I add them in the "Environment variables" part of the Run/Debug config - but they are not stored or used. (reverts back to the original setting).
Do you mean that this environment variable is not saved after you add it and close run configuration?

If so, have you tried opening and using Environment Variables window to add it?
Like that:
Hi. Yes this is exactly what I tried, and it dit not work (no changes after Apply/Save).
It kept persisting on the default value Cube2Site.settings.
I had to manually update the workspace.xml file and change the <envs> section of my Run/Debug config using a text editor.
<configuration name="Cube4Docker" type="Python.DjangoServer" factoryName="Django server">
<module name="cube2" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="DJANGO_SETTINGS_MODULE" value="Cube2Site.settings-local" />
</envs>
So - my problem is solved for now, but it would be good to know why PyCharm would not update this via the UI.
Hmmm, that's interesting.
Could you please report it to https://youtrack.jetbrains.com/issues/PY and attach your idea.log file from Help | Show Log in... after reproducing the problem?
Exactly the same fault for IntelliJ #IC-192.7142.36