Django-跳过数组的第一行 [英] Django - skip first row of array
本文介绍了Django-跳过数组的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个很简单的问题,但是似乎找不到一个简单的解决方案。
我想遍历Django模板中的数组,但跳过第一个值。
I have a fairly simple question, but I can't seem to find a simple solution to it. I'd like to iterate through an array in my Django template but skip the first value.
让我说我有一个这样的数组,我将其传递给通过视图查看我的模板:
Let's say I have an array like this that I pass to my template through a view:
array = ['1', '2', '3', '4', '5']
在我的模板中,我这样做:
In my template I do :
{%in a in array%}
{{a}}
{%endfor%}
{% for a in array %} {{ a }} {% endfor %}
我该怎么办?打印'2''3''4''5',不带第一个值?
How can I do to only print '2' '3' '4' '5', without the first value ?
推荐答案
{% for a in array|slice:"1:" %}{{ a }}{% endfor %}
请参见 https://docs.djangoproject.com/en/1.3 / ref / templates / builtins /#slice 了解更多信息。
这篇关于Django-跳过数组的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文