ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is und
2012-09-21 23:10
591 查看
Running E:\web\django\Django-1.4.1\django\bin\myadmin\myadmin\urls.py
Traceback (most recent call last):
File "E:\web\django\Django-1.4.1\django\bin\myadmin\myadmin\urls.py", line 2, in <module>
from django.contrib import admin
File "C:\Python27\lib\site-packages\django\contrib\admin\__init__.py", line 3, in <module>
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
File "C:\Python27\lib\site-packages\django\contrib\admin\helpers.py", line 2, in <module>
from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
File "C:\Python27\lib\site-packages\django\contrib\admin\util.py", line 1, in <module>
from django.db import models
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 11, in <module>
if DEFAULT_DB_ALIAS not in settings.DATABASES:
File "C:\Python27\lib\site-packages\django\utils\functional.py", line 184, in inner
self._setup()
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
解决方法:
>>> from django.template import Template, Context
>>> from
django.conf import settings
>>> settings.configure() //添加这两句
>>> t = Template('My name is {{ my_name }}.')
>>> c = Context({'my_name': 'Daryl Spitzer'})
>>> t.render(c)
u'my_name is Daryl Spitzer' //输出
Traceback (most recent call last):
File "E:\web\django\Django-1.4.1\django\bin\myadmin\myadmin\urls.py", line 2, in <module>
from django.contrib import admin
File "C:\Python27\lib\site-packages\django\contrib\admin\__init__.py", line 3, in <module>
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
File "C:\Python27\lib\site-packages\django\contrib\admin\helpers.py", line 2, in <module>
from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
File "C:\Python27\lib\site-packages\django\contrib\admin\util.py", line 1, in <module>
from django.db import models
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 11, in <module>
if DEFAULT_DB_ALIAS not in settings.DATABASES:
File "C:\Python27\lib\site-packages\django\utils\functional.py", line 184, in inner
self._setup()
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
解决方法:
>>> from django.template import Template, Context
>>> from
django.conf import settings
>>> settings.configure() //添加这两句
>>> t = Template('My name is {{ my_name }}.')
>>> c = Context({'my_name': 'Daryl Spitzer'})
>>> t.render(c)
u'my_name is Daryl Spitzer' //输出
相关文章推荐
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is und
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is und
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is und
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is un
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
- Python & Django EROOR--ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE...
- Python错误处理-ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MO
- ImportError: Settings cannot be imported, because environment variable DJANGO_SE
- [Python] ImportError: Settings cannot be imported, because environmentvariable DJANGO_SETTINGS_MODUL
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. 错误解决方法
- Django ImportError: Settings cannot be imported
- ImportError: Settings cannot be imported
- The command could not be located because '/sbin' is not included in the PATH environment variable
- django 解决: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.c
- django Settings cannot be imported 错误解决
- ImportError: Settings cannot be imported, becau...
- the command could not be located because '/bin' is not included in the path environment variable
- 针对Error: You must either define the environment variable DJANGO_SETTINGS_MODULE ...问题的解决
- Eclipse Some projects cannot be imported because they already exist in the workspace
- eclipse 中添加工程 Some projects cannot be imported because they already exist in the workspace