1.ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
需要在开头加上
from django.conf import settings
settings.configure()
两句。
>>> from django.conf import settings
>>> settings.configure()
>>> from django.template import Template
>>> print Template("My name is {{name}}")
<django.template.base.Template object at 0x01BDA890>