标签:
模板有三种使用方法
views
from django.template import loader, Context, template from django.http import HttpResponse from django.shortcuts import render_tp_response def index1(req): t = loader.get_template(‘index.html‘) c = Context({‘usename‘:‘jlan‘}) return HttpResponse(t.render(c)) def index2(req): t = Tempate(‘<h1>hello, {{username}}</h1>‘) #创建模板 c = Context({‘username‘:‘jlan‘}) return HttpResponse(t.render(c)) def index3(req): return render_to_response(‘index.html‘, {‘username‘:‘jlan‘})
标签:
原文地址:http://my.oschina.net/jlan/blog/505398