I'm working on a Django project and want to set the DJANGO_SETTINGS_MODULE environment variable in my virtualenv. All the solutions I can find on the internet use UNIX shell commands, and I'm running Windows 10. How can I set the environment variable? I'm using virtualenvwrapper if that makes a difference.
Inside of your virtual environment locate the Scripts\activate.bat script. There you can add some commands to initialize shell variables with the set command. For your project, you may want something like
set DJANGO_SETTINGS_MODULE=settings.local
Once you deactivate the virtual environment, the environment variable will persist and may conflict with that of another environment. Thus, it is good practice to unset environment variables in virtual environments. You can do this by adding the following to the Scripts\deactivate.bat script.
set DJANGO_SETTINGS_MODULE=
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With