2014-03-24 30 views
0

我有三個文件:Django的模板如何重新使用模板HTML文件兩次

  1. base.html文件
  2. results.html擴展base.html文件
  3. results_only.html(獨立)

results_only.html僅與ajax一起調用並僅返回<tr>字段。那些<tr>行目前重複在results.html,我寧願讓它們不被複制。

我如何 「進口」 results_only.htmlresults.html ...喜歡的東西:

文件results.html

{% extends "base.html" %} 
{% block header%}...{% endblock%} 
{% block content} 
<div>Results Are:</div> 
<table> 
    <tbody> 
     {% import "results_only.html" %} 
    </tbody> 
</table> 
{% endblock %} 

我寧願不重複的results_only.html的內容在兩個地方。

希望我的問題很明確。

回答