django模板报错:Requested setting TEMPLATE_DEBUG, but settings are not configured. You must either define
转自:http://blog.csdn.net/xiaowanggedege/article/details/8651236
django模板报错:
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.
好的解决办法:
先导入settings
>>> from django.conf import settings
>>> settings.configure()
>>> from django import template
>>> t = template.Template('My name is {{ name }}.')
>>> c = template.Context({'name': 'yixiaohan'})
>>> print t.render(c)
My name is yixiaohan.
>>> c = template.Context({'name': 'xiaowangge'})
>>> print t.render(c)
My name is xiaowangge.