Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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,,,

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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.

share|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. –  iDarine Feb 17 '11 at 10:16
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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