what difference between
return templateresponse(request, self.template_name, context=context)
and
return render(request, self.template_name, context=context)
is there scenario why should use 1 of them , not other?
a templateresponse
delays rendering of template until after view finished. allows template response middleware run on response, , potentially alter template or context data before template rendered. after template response middleware has run, template rendered, , normal response middleware run on rendered content before response returned client.
the render()
shortcut renders template , returns httpresponse
.
Comments
Post a Comment