Friday, October 4, 2019

for loop template

from the view i give to the template the following variables

selezione = Dbasedett.objects.filter(idbase=mod_id, revdbase=rev_test)
lista = ['test', 'test_one']

Than i return render(.........{'selezione':selezione, 'lista':lista}

In the form i need to do this:

<table>
        
        {% for dati in selezione %} 
            <tr class={% cycle 'odd' 'even' %}>
            <td>{{ dati.pos }}</td> <td>{{ dati.matr }}</td> <td>{{ lista.forloop.counter0 }}</td>
            </tr>
        {% endfor %}

But {{ lista.forloop.counter0 }} is empty 

Any help

thanks
       

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ebb1381a-02a7-46b9-b9c1-0d064596bed7%40googlegroups.com.

No comments:

Post a Comment