'why does for loop not working in django template

this is my views :

rooms = [
    {'id': 1, 'name': 'room-1'},
    {'id': 2, 'name': 'room-2'},
    {'id': 3, 'name': 'room-3'},
    {'id': 4, 'name': 'room-4'},
]

def rooms(request):
    return render(request, 'rooms.html', {'rooms': rooms})

and template codes :

{% for room in rooms %}
    <li>{{room.id}} -- {{room.name}}</li>
{% endfor %}

unfortunately for loop is not working.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source