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

135 views
Skip to first unread message

totechess

unread,
Jun 25, 2012, 1:49:01 AM6/25/12
to Django users
Tengo el siguiente problema. Con la última actualización de django 1.5
supongamos estoy en un directorio x y al hacer django-admin
startproject miProyecto me genera la carpeta miProyecto con la
siguiente estructura

manage.py
miProyecto/
__init__.py settings.py urls.py wsgi.py

al posicionarme en el directorio raiz del proyecto me lanza el
siguiente error
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

Anterior a esta version no me generaba esta estructura de archivos.
¿Como puedo corregir el problema?

bruno desthuilliers

unread,
Jun 26, 2012, 9:03:32 AM6/26/12
to django...@googlegroups.com
Désolé, je ne parle pas espagnol...

alvaroalo

unread,
Jun 26, 2012, 9:53:25 AM6/26/12
to django...@googlegroups.com


On Monday, June 25, 2012 7:49:01 AM UTC+2, totechess wrote:
Hola totechess,

En el script wsgi.py debes definir esa variable

path = os.path.dirname(os.path.abspath(__file__)) + '/..'
path2 = os.path.dirname(os.path.abspath(__file__))
if path not in sys.path:
    sys.path.append(path)
if path2 not in sys.path:
    sys.path.append(path2)

os.environ['DJANGO_SETTINGS_MODULE'] = 'miProyecto.settings'

¿Lo tienes así configurado?

Un saludo,
Alvaro
Reply all
Reply to author
Forward
0 new messages