[Answered ]-What defines iterator name in for loop template tag?

1πŸ‘

βœ…

but I can’t find any information about what is athlete_list and where is from.

This is a context variable. You can for example pass this with render(…):

def my_view(request):
    # …
    render(request, 'the-template.html', {'athlete_list': ['list', 'of', 'athletes']})

For a ListView, you can set the variable name that is associated with the QuerySet through the context_object_name attribute [Django-doc]. By default this is modename_list, so if the model is Athlete, then it is athlete_list:

class AthleteListView(ListView):
    model = OtherThanAthlete
    context_object_name = 'athlete_list'

Leave a comment