-1
我必須做在裏面Django的模板環路一些計算,但它不是解析Python代碼在for循環中,並給予錯誤怎麼辦計算在for循環中在Django模板
{% for ticket in tickets_in_cart %}
<div class="davis-date-time">
<h3>{{ ticket.performance_id__event_start_date|date:"M d" }}</h3>
<p>{{ ticket.performance_id__timing }}</p>
</div>
<div class="davis-date-time">
<h3>{{ ticket.performance_id__city }}</h3>
<p>{{ ticket.performance_id__venue }}</p>
</div>
{% singleAmount = ticket.tickets_count*ticket.tickets_amount %}
{% finalAmount += singleAmount %}
{% endfor %}
我要這樣做是因爲我需要在for循環之外打印這個finalAmount變量值。
那是因爲它不是python。 – Sayse