from django.template import Template,Context,loader def index(req): t = loader.get_template("index.html") c = Context({ }) #return HttpResponse(loader.get_template("index.html").render({})) return HttpResponse(t.render(c)) def gettext(): try: leftnav_template = ''' <div class=""> <h1> Hello</h1> ''' text = Template(leftnav_template).render(Context({})) return text except: print traceback.format_exc() logger.info(traceback.format_exc()) return ""
标签:index,return,render,django,响应,html,template,loader From: https://www.cnblogs.com/boye169/p/17616887.html