# For a monolithic project, just run the function from the project folder.
#
# For a reusable app, run the function from the folder containing the settings
# file, and pass the settings file as an argument.
# E.g. ``djsetup somecoolsite_settings.py``

djsetup()
{
    if [ x"$1" != x ]; then
        export PYTHONPATH=$PWD
        export DJANGO_SETTINGS_MODULE=$(basename $1 .py)
    else
        cd ..
        export PYTHONPATH=$PWD
        export DJANGO_SETTINGS_MODULE=$(basename $OLDPWD).settings
        cd $OLDPWD
    fi
}