python - How to create a global variable in django template? -


i'm doing loop inside template, well, want verify if actual object equal object comes before this.

this tamplate code:

    {% in format_data %}         <li>             {% first=i %}                 {{forloop.counter}}                 {% if forloop.counter == 1 %}                      <table class="format-table">                         <tr>                             <td data-format-id="{{i.format_name.id}}">{{i.format_name}}</td>                             <td>{{i.field_name}}</td>                              {% if i.field_format_data %}                                 <td>{{i.field_format_data}}</td>                             {% else %}                                 <td>campo não preenchido</td>                             {% endif %}                         </tr>                     </table>                 {% elif second == first %}                     <table class="format-table">                         <tr>                             <td>{{i.field_name}}</td>                              {% if i.field_format_data %}                                 <td>{{i.field_format_data}}</td>                             {% else %}                                 <td>campo não preenchido</td>                             {% endif %}                         </tr>                     </table>                 {% endif %}             {% endwith %}             {% second=i %}             {% endwith %}         </li>     {% endfor %} 

what want set variable in final of loop receive actual object , in next time loop works, verify if actual object equal last

you can't create global variable in template, , should avoid trying create variables there @ all.

if want check value between iterations, can use cycle tag.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -