Django + Bootstrap + 崩溃 + Item.PK = 问题

Django + Bootstrap + Collapse + Item.PK = Issue

如果我使用 {{forloop.count}}{{object.pk}} 进行 ID 和 href 呈现,则折叠不起作用,但如果我对 ID 和 href 进行硬编码,它会正常工作。这可能是什么问题?

我的模板:

{% for Entry in object_list %}
    <li style="list-style-type: none; margin-bottom: 2px;">
        <a data-toggle="collapse" href="#{{ Entry.pk }}">+</a>
        <big><a style="text-decoration: none;" target="_blank" href="{{ Entry.url }}">{{ Entry.title }}</a></big> <small style="color: tomato;">[{{ Entry.tickers|upper }}] </small><small style="color: silver;">[{{ Entry.domain }}] <i>{{ Entry.timestamp|shortnaturaltime }}</i> </small>
        <div class="collapse" id="{{ Entry.pk }}">{{ Entry.summary }}</div></li>
{% empty %}
    <li>No listings yet.</li>
{% endfor %}

HTML:

<li style="list-style-type: none; margin-bottom: 2px;">
        <a data-toggle="collapse" href="#666743">+</a>
        <big><a style="text-decoration: none;" target="_blank" href="http://title.io">Title</a></big> <small style="color: tomato;">[TAG] </small><small style="color: silver;">[title.io] <i>4h</i> </small>
        <div class="collapse" id="666743">La marca y el logo que en...</div></li>

这很好用:

<a data-toggle="collapse" href="#collapse">+</a>
<div class="collapse" id="collapse">Craft beer labore wes anderson cred nesciunt sapiente ea proident.</div>

使用按钮的工作解决方案:

<button type="button" data-toggle="collapse" data-target="#{{ Entry.pk }}" aria-expanded="false" aria-controls="{{ Entry.pk }}">+</button>