2015-04-08 111 views
0

當使用在Django模板下面的代碼:此XML文件似乎沒有任何與其關聯的樣式信息。文檔樹顯示below.2

<!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. 

爲什麼?我能做些什麼來解決它?

解決:通過改變上的HttpResponse選擇render_to_response

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") 
+2

我們如何重現這個錯誤? –

+0

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

+0

@AndreyEremchuk您在哪裏看到錯誤?簡單地在瀏覽器中打開HTML文件應該永遠不會產生這樣的錯誤... – har07

回答

0

你必須用這個替換您的內容的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"> 
相關問題