miércoles, 28 de septiembre de 2011

DJANGO_SETTINGS_MODULE... The simplest way to configure!

Looking for simple and efficient way to configure my environment to develop different django apps, and set the environment variable DJANGO_SETTINGS_MODULE on the fly, I found this function to bash us greatly simplifies our work.
You just have to edit and add user bash_profile
function setdsm() {
# add the current directory and the parent directory to PYTHONPATH
# sets DJANGO_SETTINGS_MODULE
export PYTHONPATH=$PYTHONPATH:$PWD/..
export PYTHONPATH=$PYTHONPATH:$PWD
if [ -z "$1" ]; then
x=${PWD/\/[^\/]*\/}
export DJANGO_SETTINGS_MODULE=$x.settings
else
export DJANGO_SETTINGS_MODULE=$1
fi

echo "DJANGO_SETTINGS_MODULE set to $DJANGO_SETTINGS_MODULE"
}
And then from our project directory run:
user$ setdsm

I hope this functios will be as as useful for you as is for me.

Link to source

No hay comentarios:

Publicar un comentario