render#如下代码功能相同
from django.shortcuts import render
def my_view(request):
# View code here...
return render(request, ‘myapp/index.html‘, {"foo": "bar"},
content_type="application/xhtml+xml")
from django.http import HttpResponse
from django.template import RequestContext, loader
def my_view(request):
# View code here...
t = loader.get_template(‘myapp/index.html‘)
c = RequestContext(request, {‘foo‘: ‘bar‘})
return HttpResponse(t.render(c),
content_type="application/xhtml+xml")