我是 django 的初学者,在使用 django 的模板模块时遇到了很多错误。以下从 python shell 工作:
from django import template
t = template.Template('My name is {{ name }}.')
当我使用此代码时,我收到以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/django/template/base.py", line 123, in __init__
if settings.TEMPLATE_DEBUG and origin is None:
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting TEMPLATE_DEBUG,but
settings are not configured. You must either define the environment variable
DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
有人知道这个错误吗?