我需要在這本字典中動態地獲取totale的值:
{
"periodo": "2021-12",
"corrispettivi": {
"10.00": {
"totale": -100.0,
"imposta": -9.09,
"imponibile": -90.91
},
"22.00": {
"totale": 10773.81,
"imposta": 1942.82,
"imponibile": 8830.99
}
},
"saldo": {
"totale": 10673.81,
"imposta": 1933.73,
"imponibile": 8740.08
},
"ndc": 782,
"ingressi": 782
},
在我的模板中
{% for entrata in entrate %}
<h3>Periodo: {{ entrata.periodo }}</h3>
<table style="width:100%">
<thead>
<tr>
<th></th>
<th style="text-align:right">TOTALE</th>
<th style="text-align:right">IMPOSTA</th>
<th style="text-align:right">IMPONIBILE</th>
</tr>
</thead>
<tbody>
{% for corrispettivo in entrata.corrispettivi %}
<tr>
<th>IVA {{corrispettivo}} %</th>
<td>{{corrispettivo.totale}}</td>
<td>{{corrispettivo.imposta}}</td>
<td>{{corrispettivo.imponibile}}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
但corrispettivo.totale不起作用
我試過這個指南
但我不明白它是如何作業的
如何訪問totale的值?
uj5u.com熱心網友回復:
試試這個:
{% for key, value in entrata.corrispettivi.items %}
<tr>
<th>IVA {{key}} %</th>
<td>{{value.totale}}</td>
<td>{{value.imposta}}</td>
<td>{{value.imponibile}}</td>
</tr>
{% endfor %}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/395927.html
