在HTML(Django)中使用Python for循环时自动转换图像文件的名称

在HTML(Django)中使用Python for循环时自动转换图像文件的名称,python,django,Python,Django,我正试图为practice Django创建自己的博客 在索引页中,有几个图像。 这些图像的名称是'image1.jpg./'image2.jpg'/'image3.jpg' 我想在html中使用for循环来显示这些图像 这是我的代码,它不工作。 (我使用forloop.counter) 你有什么想法吗?谢谢 (对不起我的英语…) {%for post in lastest_post%} {%if-forloop.first%} {%if post.is_content_more320%} {

我正试图为practice Django创建自己的博客

在索引页中,有几个图像。 这些图像的名称是'image1.jpg./'image2.jpg'/'image3.jpg'

我想在html中使用for循环来显示这些图像

这是我的代码,它不工作。 (我使用forloop.counter)

你有什么想法吗?谢谢 (对不起我的英语…)

{%for post in lastest_post%}
{%if-forloop.first%}

{%if post.is_content_more320%}
{{post.get_content_320}
{%else%}
{{post.content}}
{%endif%}

2017年2月25日类别 {post.category.all%} {{c}} {%if不是forloop.last%} , {%endif%} {%endfor%} {%else%}
{% for post in lastest_post %}
{% if forloop.first %}
    <div class="col-md-12">
        <div class="single-post-big">
        <div class="big-image">
            <img src="{% static 'img/post-image{{ forloop.counter }}.jpg' %}" alt="">
        </div>
        <div class="big-text">
            <h3><a href="{{ post.get_absoulte_url }}">{{ post.title }}</a></h3>
            <p>
                {% if post.is_content_more320 %}
                    {{ post.get_content_320 }}
                {% else %}
                    {{ post.content }}
                {% endif %}
            </p>
            <h4><span class="date">25 February 2017</span><span class="author">Category 
                <span class="author-name">
                    {% for c in post.category.all %}
                        {{ c }}
                        {% if not forloop.last %}
                            ,
                        {% endif %}
                    {% endfor %}
                </span>
            </span>
            </h4>
        </div>
    </div>
</div>
{% else %}