1) you forgot to include {% endfor %} in you template
mylist = ['aa','bb']
return render(....{'mylist':mylist})
Then in your template:
<tr>
{% for a in mylist %}
<td>{{ mylist }}</td>
{% endfor %}
</tr>
{% for a in mylist %}
<td>{{ mylist }}</td>
{% endfor %}
</tr>
On Wed, Oct 9, 2019 at 9:17 AM Luca Bertolotti <luca72.bertolotti@gmail.com> wrote:
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.
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/CAHyB84pPtNxB1iPuOiKBi_nuk1syze5zeB2KraERdOPoh5yriA%40mail.gmail.com.
No comments:
Post a Comment