Hi
I have different settings file for dev, testing and production. I also have custom variables inside these settings files. (values must be changing depends on env)
How can I import/get the correct value from the settings file depends on current environment?
Your asgi/wsgi.py file has a statement that is importing the settings module. You can alter the path in this statement to change the settings.py file that is loaded. From there you should be able to import any variables from the settings.py file into other files.
I would avoid changing that value directly in the asgi/wsgi.py files. It’s better to change the environment that controls the settings module. This topic was discussed previously on the forum at Setting the 'django_settings_module' value. Hopefully that topic provides some clear guidance.
I’m sorry, I don’t know too much about VS Code. I used it briefly while playing with Rust, but I mostly stick with Vim.
Outside of code editors, you can use a tool like django-environ to read environment variables from a .env file that lives at your repository root. The nice part about this package is that it’s editor agnostic so if you work on a team, then anyone is able to handle environment variables in the same way, regardless of their editor choice.