2
我有一個項目應用程序和一個文件應用程序。在project.html文件中,我想包含file_list.html文件。使項目頁面上顯示與項目對應的所有文件。Django:包含來自其他應用程序的模板
project.html(工程應用)
{% extends "site_base.html" %}
...
{% block body %}
...
<div id="files">
<p>More here soon but in the meantime, here's a link to the
<a href="{% groupurl file_list project %}">file list</a>
</p>
</div>
...
{% endblock body %}
而不是這裏的鏈接到文件列表,我想直接將文件列表。
file_list.html(檔案應用程式)
{% extends "site_base.html" %}
{% block body %}
{% for file in files %}
<tr>
<td>{{ file.filename }}</td>
</tr>
{% endfor %}
{% endblock body %}
我想出了以下的可能性,但我不知道什麼實際工作和最佳實踐
- 包括file_list.html與{%include%}。但比我缺少的情況下,將文件
- 寫一個使用inclusion_tag
- 使用{%塊%}
- 使用模板裝載機
什麼是在這種情況下,最好的解決辦法。還有其他的可能嗎?