在settings.py中加入模板路径:
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'),
)
os.path.dirname(__file__)将会获取settings.py所在的目录路径。
在view.py中使用:
t=get_template('thank.html')
html=t.render(Context({'person_name':'Jake','company':'company','ship_date':now}))
get_template需要引入from django.template.loader import get_template