Django template not rendering second value in passed context tuples

I am trying to apply custom values to specific styles. In my static style sheet, which works if I list the items separately but not if I try to populate the style with a for loop.

I have created a set of specific styles:

  .item_1, .item_2, .item_3, .item_4, .item_5, .item_6, .item_7, .item_8 {
    width: 8vw;
    height: 14vh;
    padding: 10px;
    align-content: center;
    background-color: white;
    border: 2px solid black;
    
    display: inline-block;
    vertical-align: middle;
    text-align: center;
    font-size: 2vh;
    border-radius: 15px;
    box-sizing: border-box;
  }

each one corresponds to a specific item in a flex box to render:

in order to be able to change the background color as required.

changing colors via hardcoding works fine using a list of colors via context, i.e:

div.item_1 {
        background-color: {{ color.0 }};}```

however, if I use zip to create a set from two lists, div.item_1 ... and color, it renders a blank style:

 {
    background-color: ;}

The result of:

divcontext_colors_zip = list(zip(divcontext,area_colors))```

is:

[('div.item_1', 'Red'), ('div.item_2', 'Yellow'), ('div.item_3', 'Yellow'), ('div.item_4', 'Green'), ('div.item_5', 'Yellow'), ('div.item_6', 'Yellow'), ('div.item_7', 'Green')]

and is passed as divcontext_colors_zip:

 "divcontext_colors_zip": divcontext_colors_zip,

the loop I use is:

<style>

    {% for x_topics in divcontext_colors_zip %}
    {{ x_topics.divcontext}} {
        background-color: {{ x_topics.area_colors }};}
    {% endfor %}

If:

divcontext_colors_zip = [
    ('div.item_1', 'Red'), 
    ('div.item_2', 'Yellow'), 
    ('div.item_3', 'Yellow'), ...
]

Then each iteration in:

means that x_topics is going to be a reference to a tuple in that list.

There are no attributes named divcontext or area_colors in those tuples.

The references would be x_topics.0 and x_topics.1

Thanks again. Works great. I am trying to make teh code as general as possible for reuse with other ISO’s.

I had used that format because I used that format for the results of a database query. From that and your answer it looks like a database query from X.objects… retains the attributes so you use those names while the tuples do not, the zip(x,y) only uses x and y to identify the lists to zip and you get specific values w o,1,2… depending on teh number of zipped lists.