首页 > 代码库 > django模板报错:Requested setting TEMPLATE_DEBUG, but settings are not configured. You must either define
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.
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。