开发者

Doing a for loop within a template

I want to a do for loop like (for int x = 0; x < 3; x++) in a django template. How should I do it? Pseudo code looks like the following:

{% for Summary in Summary_list %}
        {开发者_高级运维% ifchanged Summary.bu_id %}
            </tr>
            <tr>
            <td>{{Summary.bu.version}}</td>
            {% if Summary.platform_id != 1 %}
                {% for x less than Summary.platform_id %}
                        <td><center>-</center></td>
                        {% x++ %}

{# How Should I do this part? #}

            <td> <center>{{Summary.successCount}}</center></td>
        {% else %}
            <td><center> {{Summary.successCount}}</center></td>
        {% endifchanged %}
    {% endfor %}

Thank you very much!


Use the template range filter in this snippet. (For background on using custom filters consult the documentation.)

Then you should be able to do something like:

{% for x in Summary.platform_id|get_range %}

...

{% endfor %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜