Wednesday, October 9, 2019

list cycle in template

Hello in the view a hve a list
mylist = ['aa','bb']
n = range(len(mylist))

return render(....{'mylist':mylist,'n':n,.....})

in the template i do this:

<tr>{% for a in n %} <td>{{ mylist.a }}</td></tr>

it never show nothing, but if i do:

<tr>{% for a in n %} <td>{{ mylist.0 }}</td></tr>
it show 'aa'

Where is the mistake?

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/af0a2286-6bf9-4b9e-9a77-626ae5309ee6%40googlegroups.com.

No comments:

Post a Comment