为什么我的循环在所有项目循环通过之前终止?

2024-06-11 21:59:51 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,我正在使用Django,并尝试使用githubs嵌入的GIST将用户GIST动态添加到页面中

这是循环

{% for i in snippets %}
    <div class="tile is-4">
        <div style="height:25vh;"><script src="https://gist.github.com/{{i.owner.login}}/{{i.id}}.js"/></div>
    </div>
{% endfor %}

im循环遍历的列表包含两项,但只添加了第一项。 但是,如果我沿着这些线做一些事情,它会正确地显示两个不同的id

{% for i in snippets %}
   {{i.id}}
{% endfor %}

我读到github脚本调用document.write(),我有一种直觉,这就是我的问题所在

document.write()会打破我的循环吗


Tags: django用户indivgithubidfor动态