[Django]-Raise ImportError("Settings cannot be imported, because environment variable %s is undefined

3👍

I run this script whenever I open a new shell:

export PYTHONPATH=$PYTHONPATH:/Users/cole/Projects/Sites/my_project.com/my_project
export DJANGO_SETTINGS_MODULE=my_project.settings

UPDATE: I had edited the script in a little sloppily. All that is needed is:

export PYTHONPATH=$PYTHONPATH:/Path/To/Project/Root/Directory
export DJANGO_SETTINGS_MODULE=my_project.settings
👤Cole

1👍

Go to your project folder where manage.py is available and run:

python manage.py shell

run the django statements which through error. (It should work here)

Leave a comment