强制性的“我是Django的新手”..。
在我看来,我正在创建一个名为records_list的列表。在该列表中,我在该位置上有另一个列表,在位置1中有一个字典,如下所示:
records_list = list()
list_one = Bet.objects.order_by('-game_date')
list_two = {}在"list_two“(我的字典)中,我有一个键,它是一个日期为”2016 4月“的ex,以及一个元组的值:
list_two[aux_month_year] = (aux_wins, aux_losses, aux_voids, s_rate, i_rate, profit)因此,我将这个返回到我的html:
records_list.append(list_one)
records_list.append(list_two)
return records_list在html中,我想创建一个表,首先检查我的利润是否为正数:
{% if records_list %}
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Wins</th>
<th>Losses</th>
<th>Void</th>
<th>Success Rate</th>
<th>Return on Investment</th>
<th>Profit</th>
</tr>
</thead>
{% for key in records_list.1 %}
{% if ((records_list.1.key.5) > 0) %}
<tr class="success">
<td>{{ key }}</td>
<td>{{ records_list.1.key.0 }}</td>
<td>{{ records_list.1.key.1 }}</td>
<td>{{ records_list.1.key.2 }}</td>
<td>{{ records_list.1.key.3 }}%</td>
<td>{{ records_list.1.key.4 }}%</td>
<td>{{ records_list.1.key.5 }}</td>
</tr>但是,我在这里得到了以下语法错误:
{% if ((records_list.1.key.5) > 0) %}错误:
Could not parse the remainder: '((records_list.1.key.5)' from '((records_list.1.key.5)'如果有人能帮我,把我引向正确的方向,我将不胜感激!谢谢
发布于 2016-04-11 14:00:13
if标记不支持括号。来自医生们
在if标记中使用实际括号是无效的语法。如果需要它们来指示优先级,则应使用嵌套的If标记。
在您的情况下,不需要括号,所以只需删除它们:
{% if records_list.1.key.5 > 0 %}https://stackoverflow.com/questions/36550797
复制相似问题