So, I am studying the Django book and the django documentation, and I cannot understand this example:
<ul> {% for athlete in athlete_list %} <li>{{ athlete.name }}</li> {% endfor %} </ul>
This is about templates, and I donβt understand how to encode the context. How can I get the name attribute from the list? If I create a dictionary, it will not be possible to use for a loop, as in this example. I encoded it like this, but it does not work:
athlete_list = {'name' = ['Athlete1', 'Athlete2', 'Athlete3']} Context({'athlete_list':athlete_list})
if I change the athlete_list variable to a regular list (not a dictionary), "athlete.name" in the template will not work either. I do not think this is a mistake in the book, and it is probably very easy to solve, but I cannot get it.
source share