此XML文件似乎没有与之关联的任何样式信息。文档树如下所示

时间:2015-04-08 12:41:05

标签: python html css xml django

在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")

1 个答案:

答案 0 :(得分: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">