django表信息显示两次

时间:2014-12-03 02:16:47

标签: django

django表信息显示两次

为什么剩余的截止日期和时间出现两次?我正在努力弄清楚那是什么来自。我还在慢慢地学习django。有时,我遇到了麻烦。

照片: http://gyazo.com/cae11df54df3f558865a772529f97139.png

.html代码

            {% if toolsBorrowed %}
            <table id="dataTable" width="100%" cellspacing="0" cellpadding="5" class="table table-hover">
                <thead>
                    <tr>
                        <th>Tool Name</th>
                        <th>Owner</th>
                        <th>Due Date</th>
                        <th>Time Remaining</th>
                    </tr>
                </thead>
                <tbody id="myTable">
                    {% for tool in toolsBorrowed %}
                        {% query Request borrowerId=user.id as req %}   
                        {% query userAcc pk=tool.owner as owner %} 
                        <tr style="cursor: pointer;" onclick="document.location = '/view_tool/{{ tool.id }}/';">
                            <td>{{ tool.name }}</td>
                            <td>{% for o in owner %}{{ o.username }}{% endfor %}</td>
                            {% for r in req %}

                                <td>{{ r.dueDate }}</td>
                            <td>{{ r.dueDate | timeuntil }}</td>
                            {% endfor %}
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% else %}
                <strong>You are not borrowing any tools.</strong>
            {% endif %}

views.py

def borrowed(request):
    context = {'toolsBorrowed': Tool.objects.filter(borrower = request.user.id),
                'toolsLoan':Tool.objects.filter(owner = request.user.id).exclude(borrower = None),
               'userAcc' : userAcc.objects,
               'Request' : Request.objects,
               }    
    return render(request, 'borrowed.html', context)

任何帮助都会很棒。

0 个答案:

没有答案