django模板报错Requested setting TEMPLATE_DEBUG, but...
2016-06-23 10:15
399 查看
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.
直接python命令启动python交互式解释器,导入django template会报错。
解决方法一:
# -*- coding:utf-8 -*-
from django.conf import settings
settings.configure()
from django.template import Template,Context
s='My name is {{name}}'
t=Template(s)
c=Context({'name':'lixiaotao'})
print t.render(c)
解决方法二: 使用python manage.py shell启动 Python交互式解释器(实际上启动的是Ipython) python manage.py shell
相关文章推荐
- Elasticsearch TermQuery 详解
- UITableView:下拉刷新和上拉加载更多
- easyui页面上显示和PL/SQL编码问题
- Leetcode Longest Consecutive Sequence
- UIView设置指定角为圆角的代码
- 应用Druid监控SQL语句的执行情况
- vue.js快速上手。
- 修改UITextfield的Placeholder字体的颜色
- iOS UITextView 限制最大输入字数
- iOS-你真的会用UIMenuController吗?(详细)
- android stuido使用以及markdown编辑器语法
- LeetCode-62-Unique Paths
- QueryPerformanceCounter函数
- RegQueryValueEx函数
- RegSetValueEx和RegDeleteValue函数
- CreateIoCompletionPort和GetQueuedCompletionStatus函数
- HDFS UserGuide
- 关键字彩蛋动画的实现(讲解+DEMO)
- UGUI Scrollrect滚动优化:无限循环利用
- Android UI设计技巧