无论出于何种原因,我都无法在本地复制此问题,但在我的一个模板中的生产服务器上,重组标签正在做一些奇怪的事情。我正在尝试对所有具有相同pickup_id 的捐赠进行分组,并仅显示其中有多少被“错过”。出于某种原因,它在我的列表中多次显示相同的pickup_id。
看法
missed_routes = Donor.objects.filter(missed='YES').order_by('pickup_date')
模板
{% block content %}
{% regroup missed_routes by pickup_id as missed_pickups %}
<div class="missedColumn">
<h2>Missed Donations</h2>
<p>Looks like we have some stragglers…</p>
<p>These routes have missed donations in them.</p>
{% for routes in missed_pickups %}
<p><a href="/reschedule/{{ routes.grouper }}">{{ routes.list.0.route }}</a> - {{ routes.list.0.pickup_date }} ({{ routes.list|length }} missed - {{ routes.list.0.pickup_id }}</p>
{% endfor %}
</div>
结果 html # 600 是pickup_id
<p><a href="/reschedule/600">Syosset</a> - Sept. 14, 2012 (1 missed - 600</p>
<p><a href="/reschedule/423">Huntington Station</a> - Sept. 14, 2012 (1 missed - 423</p>
<p><a href="/reschedule/600">Syosset</a> - Sept. 14, 2012 (2 missed - 600</p>
在拾取 html 输出中迭代每个捐助者时
<p><a href="/reschedule/600">Syosset</a> - Sept. 14, 2012 (1 missed - 600
<ul>
<li>134170</li>
</ul>
</p>
<p><a href="/reschedule/423">Huntington Station</a> - Sept. 14, 2012 (1 missed - 423
<ul>
<li>134938</li>
</ul>
</p>
<p><a href="/reschedule/600">Syosset</a> - Sept. 14, 2012 (2 missed - 600
<ul>
<li>134174</li>
<li>133151</li>
</ul>