How to I access the dictionary with multiple values inside list

Advertisements
my_isp_details = {'Jim': ['10.1387.32', 'Sim782']}

<table>
      <tr>
        <th>Description</th>
        <th>Source</th>
        <th>Gateway</th>
      </tr>
      {% for key, value in my_isp_details.items %}
      <tr>
        <td>{{ key }}</td>
        <td>{{ value[0] }}</td>
        <td>{{ value[1] }}</td>
      </tr>
      {% endfor %}
    </table>

How to pass the value 0 and 1 in table td. Is there any solution to pass the values

>Solution :

I think you are looking to iterate over the items in your value perhaps like this:

my_isp_details = {'Jim': ['10.1387.32', 'Sim782']}

<table>
    <tr>
        <th>Description</th>
        <th>Source</th>
        <th>Gateway</th>
    </tr>
    {% for key, value in my_isp_details.items %}
        <tr>
            <td>{{ key }}</td>
            {% for inner_value in value %}
                <td>{{ inner_value }}</td>
            {% endfor %}
        </tr>
    {% endfor %}
</table>

Leave a ReplyCancel reply