【问题标题】:This XML file does not appear to have any style information associated with it. The document tree is shown below.2此 XML 文件似乎没有任何与之关联的样式信息。文档树如下所示。2
【发布时间】:2015-04-08 12:41:04
【问题描述】:

在 django 模板中使用以下代码时:

  <!DOCTYPE html>

<html lang="en">

<head>
<link href="http://52.11.183.14/static/wiki/bootstrap/css/wiki-bootstrap.css" type="text/css" rel="stylesheet"/>
<link href="http://52.11.183.14/static/wiki/bootstrap/css/simple-sidebar.css" type="text/css" rel="stylesheet"/>
<title> Profile - Technology βιβλιοθήκη </title>
</head>
<body>
<div class="container">


    {% for p in profiles %}
     {{p}}
    {% endfor %}


</div>
</body>
</html>

我收到以下错误:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

为什么?我能做些什么来解决它?

已解决:通过更改 render_to_response 上的 HttpResponse

   my_context={'profiles': profiles}
   c = RequestContext(request,{'profiles': profiles})
   return render_to_response('wiki/profile.html',
                      my_context,
                      context_instance=RequestContext(request))
   #return HttpResponse(t.render(c), content_type="application/xhtml+xml")

【问题讨论】:

  • 我们如何重现这个错误?
  • 跳过 {% for p in profile %} {{p}} {% endfor %}
  • @AndreyEremchuk 您在哪里看到错误?简单地在浏览器中打开 HTML 文件永远不会产生这样的错误...
  • 我使用 django 模板处理器/在浏览器中简单打开

标签: python html css xml django


【解决方案1】:

你必须用这个替换你的内容 html 标签。

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

【讨论】:

    猜你喜欢
    • 2012-07-08
    • 1970-01-01
    • 2016-09-26
    • 1970-01-01
    • 2017-11-04
    • 1970-01-01
    • 1970-01-01
    • 2017-11-28
    • 2013-01-26
    相关资源
    最近更新 更多