Skip to content

Instantly share code, notes, and snippets.

@sigilioso
Created November 25, 2015 11:00
Show Gist options
  • Save sigilioso/03ae9b419440b213a830 to your computer and use it in GitHub Desktop.
Save sigilioso/03ae9b419440b213a830 to your computer and use it in GitHub Desktop.
Environment variables for python virtualenvs with virtualenvwrapper
#!/bin/bash
# This hook is run after this virtualenv is activated.
# To be in $VIRTUALENV_HOME/bin/postactivate
if [[ -n $DJANGO_SETTINGS_MODULE ]]
then
export DJANGO_SETTINGS_MODULE_BACKUP=$DJANGO_SETTINGS_MODULE
fi
export DJANGO_SETTINGS_MODULE=YOUR.VALUE
#!/bin/bash
# This hook is run after this virtualenv is deactivated.
# To be in $VIRTUALENV_HOME/bin/postdeactivate
if [[ -n $DJANGO_SETTINGS_MODULE_BACKUP ]]
then
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE_BACKUP
unset DJANGO_SETTINGS_MODULE_BACKUP
else
unset DJANGO_SETTINGS_MODULE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment