i trying initialize variable , increment in loop i'm getting following error:
invalid block tag: 'set', expected 'endspaceless'
this code:
<tr{{ row.attr_string|safe }}>     {% spaceless %}          {% set counter = 0 %}          {% cell in row %}             {% set counter= counter+1 %}             {% if counter < 4 %}                                  {%  include "horizon/common/_data_grid_cell.html" %}                       {% else %}                 {%  include "horizon/common/_data_table_cell.html" %}             {% endif %}          {% endfor %}      {% endspaceless %} </tr>      
you don't need to. django comes forloop.counter, forloop.counter0. can use directly:
<tr{{ row.attr_string|safe }}>     {% spaceless %}          {% cell in row %}             {% if forloop.counter < 4 %}                                  {%  include "horizon/common/_data_grid_cell.html" %}                       {% else %}                 {%  include "horizon/common/_data_table_cell.html" %}            {% endif %}          {% endfor %}      {% endspaceless %} </tr>      
Comments
Post a Comment