1. django-2  模板文件的加载  
  2. 1.创建模板文件 index.html  
  3. 2.在django使用模板文件  需要在app下创建templates文件夹   此为django固定模板文件位置  
  4. 3.编辑views.py文件  
  5.    添加index.html文件的使用方法  
  6. from django,template  import loader,Context  
  7. def index(req):  
  8.         t=loader.get_template('index.html')       #生成模板对象  
  9.         c=Context({})                             # 生成context对象   
  10.         return HttpResponse(t.render(c))      # 调用返回对象  
  11.  
  12. 此步骤是一步一步增加的,先增加调用模板的方法,在给模板渲染对象,此处对象为空,最后返回对象  
  13. 4.启动开发服务器 runserver  进行测试  
  14. 5.更简单的模板写法如下  
  15. from   django.shortcuts import render_to_response  
  16. def   index(req):  
  17.         return   render_to_response('index.html',{})