2012-05-05 15 views
0

我試圖創建一個Django的模板,但是當我在Python殼牌和Django

執行該判決它給了我這個錯誤模板問題

Traceback (most recent call last): 
    File "<pyshell#1>", line 1, in <module> 
    t = Template("Mi nombre es {{ mi_nombre }}.") 
    File "django\template\base.py", line 123, in __init__ 
    if settings.TEMPLATE_DEBUG and origin is None: 
    File "django\utils\functional.py", line 184, in inner 
    self._setup() 
    File "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. 

任何人都知道我怎麼能解決這個問題?

回答

1

不是直接運行python shell,而是使用Django的包裝器。

CD到項目的目錄,然後運行

python manage.py shell 

這會給你Django在何處已經成立,並已導入您的設置交互的shell。

還有其他的方法可以達到這個目標,但是這應該讓你走。

+0

謝謝!有用! – Kemical