添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
伤情的柿子  ·  python dll ...·  1 年前    · 

In case that you need to define an array in Django templates - it is not possible to do directly. Instead you can define a string with your values joined by space. Then when you need to use the array, you split the string and you have your array. For example if you want to check if an icon is available then you can do

{% with my_array='one two three five' %}
  {% if icon in my_array.split %}
    <i class="icon icon-{{icon}}"></i>
  {% else %}
    no such icon
  {% endif %}
{% endwith %}