2

On running Django, I frequently get the following error:

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

How do I set the environment variables correctly? I tried the solution here but did not have any success.

yayu
  • 3,391

1 Answers1

2

You can set an environment variable with a command like:

export DJANGO_SETTINGS_MODULE=application.settings

Assuming that application.settings is in Python's path, you should then be able to run django-admin using those settings. Alternatively, you can pass a settings module to django-admin on the command line:

django-admin --settings=application.settings ...
  • I get the error ImportError: Could not import settings 'application.settings' (Is it on sys.path?): No module named application.settings how can i set this to the python path? – yayu Apr 14 '12 at 05:00
  • No worries. I figured it out. – yayu Apr 14 '12 at 05:14