目前我正在嘗試爲一個請求創建多個視圖。 1點看,我這樣做:Django的嵌套render_to_response總是顯示內容類型
return render_to_response(
"/index/index.html",
{}
)
,現在當我嘗試了「左」列添加到index.html的,我需要把它放在不同的看法(因爲我需要應用相同的技術在其他地方也是如此),這就是我該如何做的:
leftCol = direct_to_template(request,settings.viewPath + "/columns/left.html",{})
return render_to_response(
"/index/index.html",
{
'leftColumn': leftCol,
}
代碼運行良好,但輸出結果並不符合我的預期。該leftCol顯示在開始其輸出的響應頭:
「的Content-Type:text/html的;字符集= UTF-8」
我如何刪除這個頭?我一直在嘗試修改參數中的content_type和mimetype,但它不起作用。
的leftCol用使用direct_to_template,這是選擇render_to_response以及之前。但結果是一樣的。 – kecebongsoft 2011-04-02 12:25:04
閱讀有關呈現內容的文檔:http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context另一種方法可以是使用模板標記或包含(直接在模板上級別) – Jerzyk 2011-04-02 14:22:30