Tuesday, June 26, 2012

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



On Monday, June 25, 2012 7:49:01 AM UTC+2, totechess wrote:
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?

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/VPNJlO5TzHgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment