django template出错
解决方法一:
先导入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.
解决方法二:
使用python manage.py shell启动 Python交互式解释器(实际上启动的是Ipython)
python manage.py shell