1

i installed wsgi, python, apache and django on my Ubuntu 10.04 but when i

django-admin.py runserver

i get this error

Error: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

how to solve this?any replies will be much appreciated.... and a step by step answers will be great,,,

1

DJANGO_SETTINGS_MODULE.

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"
}

put this in .bash_profile, then a quick setdsm sets the DJANGO_SETTINGS_MODULE to the settings.py in the current directory and add the current directory and it’s parent to PYTHONPATH.

Taken from: http://www.juiceanalytics.com/writing/django_settings_module/
Check this also: http://martinjansen.com/2008/10/20/django-settings-files-for-development-and-production/

Hope this helps.

|improve this answer|||||
  • export PYTHONPATH=$/home/idarine/neophyte/:$PWD/.. export PYTHONPATH=$/home/idarine/:$PWD -----------is this right?i substituted my current django directory and my parent directory. – RedKing Feb 17 '11 at 10:16
0

the problem is that you are trying to run django server using djang-admin.py runserver script instead of ./manage.py runserver. In a nutshell, you should use django-admin.py to create your application, and manage.py to run development server, commands etc for current django application, for example:

django-admin.py startproject test
cd test
./manage.py runserver

Hope this helps.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.