标签:显示 path port 代码 tin html ext 内容 顺序
DIRS=[os.path.join(BASE_DIR,"templates")]
loader.get_template(template_name),返回一个Template对象
Template对象的render(RequestContext)方法,使用context渲染模板
from django.template import loader, RequestContext
from django.http import HttpResponse
def index(request):
tem = loader.get_template(‘temtest/index.html‘)
context = RequestContext(request, {})
return HttpResponse(tem.render(context))
from django.shortcuts import render
def index(request):
return render(request, ‘temtest/index.html‘)
标签:显示 path port 代码 tin html ext 内容 顺序
原文地址:http://www.cnblogs.com/huwei934/p/6978654.html