0
如果我使用{{forloop.count}}
或{{object.pk}}
進行ID和href渲染,collapse不起作用,但是如果我硬編碼ID和href,它就像它應該那樣工作。這裏可能是什麼問題?Django + Bootstrap + Collapse + Item.PK =問題
我的模板:
{% 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>