I exported the path of my django project by

$ export DJANGO_SETTINGS_MODULE=/Users/masi/Documents/Test/djangobook/ch3.settings

I run unsuccessfully

$ django-admin.py runserver 
Error: Could not import settings '/Users/masi/Documents/Test/djangobook/ch3.settings' (Is it on sys.path? Does it have syntax errors?): Import by filename is not supported.

How can you start Django server without the error message?

Accepted Answer

Your $DJANGO_SETTINGS_MODULE should just be set to ch3.settings. Just make sure that the ch3 app is in your $PYTHONPATH, too.

For example, if your app is at /Users/masi/Documents/Test/djangobook/, then set $DJANGO_SETTINGS_MODULE to ch3.settings, and make sure your $PYTHONPATH includes /Users/masi/Documents/Test/djangobook.

$ export PYTHONPATH=/Users/masi/Documents/Test/djangobook/
$ export DJANGO_SETTINGS_MODULE=ch3.settings
Written by mipadi
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki