首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法解析剩余部分:'((records_list.1.key.5)‘from’((records_list.1.key.5))‘

无法解析剩余部分:'((records_list.1.key.5)‘from’((records_list.1.key.5))‘
EN

Stack Overflow用户
提问于 2016-04-11 13:55:01
回答 1查看 125关注 0票数 0

强制性的“我是Django的新手”..。

在我看来,我正在创建一个名为records_list的列表。在该列表中,我在该位置上有另一个列表,在位置1中有一个字典,如下所示:

代码语言:javascript
复制
records_list = list()
list_one = Bet.objects.order_by('-game_date')
list_two = {}

在"list_two“(我的字典)中,我有一个键,它是一个日期为”2016 4月“的ex,以及一个元组的值:

代码语言:javascript
复制
list_two[aux_month_year] = (aux_wins, aux_losses, aux_voids, s_rate, i_rate, profit)

因此,我将这个返回到我的html:

代码语言:javascript
复制
records_list.append(list_one)
records_list.append(list_two)
return records_list

在html中,我想创建一个表,首先检查我的利润是否为正数:

代码语言:javascript
复制
{% 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>

但是,我在这里得到了以下语法错误:

代码语言:javascript
复制
{% if ((records_list.1.key.5) > 0) %}

错误:

代码语言:javascript
复制
Could not parse the remainder: '((records_list.1.key.5)' from '((records_list.1.key.5)'

如果有人能帮我,把我引向正确的方向,我将不胜感激!谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-11 14:00:13

if标记不支持括号。来自医生们

在if标记中使用实际括号是无效的语法。如果需要它们来指示优先级,则应使用嵌套的If标记。

在您的情况下,不需要括号,所以只需删除它们:

代码语言:javascript
复制
{% if records_list.1.key.5 > 0 %}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36550797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档