【发布时间】:2017-08-24 11:20:08
【问题描述】:
project/
|----app1/
|----templates/
app1/
|----home.html
|----exchange.html
我需要使用javascript对home.html进行计算,但是有些数据存储在exchange.html内的表中,我不想将它们放在一个页面下。我该怎么做。我对 python 和 django 很陌生。
{% include "exchange.html" %}
我在 home.html 上试过这个,但它加载了我不需要的所有内容。有人可以帮忙吗。
<table class="table table-hover">
<caption>Exchange rate</caption>
<thead>
<tr>
<th></th>
<th>GBP</th>
<th>EUR</th>
<th>USD</th>
<th>CAD</th>
<th>AUD</th>
</tr>
</thead>
<tbody>
<tr>
<td>GBP</td>
<td><input type="number" value="1" readonly></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
</tr>
<tr>
<td>EUR</td>
<td><input class="rate" type="number"></td>
<td><input type="number" value="1" readonly></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
</tr>
<td>USD</td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input type="number" value="1" readonly></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<tr>
<td>CAD</td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input type="number" value="1" readonly></td>
<td><input class="rate" type="number"></td>
</tr>
<tr>
<td>AUD</td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input class="rate" type="number"></td>
<td><input type="number" value="1" readonly></td>
</tr>
</tbody>
</table>
我在exchage.html中有这张表,用户可以输入汇率,我需要用相关汇率对home.html做一些计算。
【问题讨论】:
-
创建一个单独的 html,其中包含您需要的数据并使用 include 标签将其添加到 home .html
-
在
include中提供所需.html文件的完整路径
标签: javascript python django web-applications django-templates