我正在开发一个 Django 项目,该项目从我的数据库中访问不同的表,并将这些信息全部输出在一个页面上。我这样做的方式是:
a = get_hostname(request, hostname)
b = get_systeam(request, hostname)
c = get_appteam(request, hostname)
response = HttpResponse()
response.write(a)
response.write(b)
response.write(c)
return HttpResponse(response)
所有被调用的函数都通过 render_to_response 方法返回 HTTPresponse 对象。当我使用Javascript查看连接的html时,有多个Content-Type:text/html; charset=utf-8 出现在页面上。
<h2>
<div class ="row">
<center>
<div class ="col-md-3 col-md-offset-3">
<h1>Hostname: xxxxxxx </h1>
</div>
</h2>
Content-Type: text/html; charset=utf-8
<h3>
<div class ="row">
<div class ="col-md-3 col-md-offset-2">
<h1>System Team: xxxxxx </h1>
</div>
Content-Type: text/html; charset=utf-8
<div class = "col-md-3 col-md-offset-2">
<h1>Application Team: xxxxxxxx </h1>
</div>
</div>
</h3>
我有一种感觉,我的 base.html 中的元标记没有被传递,所以当 html 块被呈现时,它们会自动添加 Content-Type 行。任何帮助表示赞赏!