django render_to_response

Sev*_*ths 1 django django-templates django-views

我正在推..

...}, context_instance=RequestContext(request))
Run Code Online (Sandbox Code Playgroud)

在我所有的结尾render_to_response.我确定这不对.任何人都可以告诉我何时应该使用这些?

ari*_*rie 5

如果您使用的是Django 1.3,则可以使用render()快捷方式功能,因此您不必context_instance=RequestContext(request)为每个视图显式写入.

将给定模板与给定的上下文字典组合,并返回带有该呈现文本的HttpResponse对象.

render()与使用context_instance参数调用render_to_response()相同,后者强制使用RequestContext.