Printing the dictionary value out in Django template

The dictionary student_ids has a key called student_id and invite_id and I would like to print out the student_ids[student_id] to get the invite_id.

Try this:

{% for sid, iid in student.ids.items %}
    {{ sid }} -- {{ iid }}
{% endfor %}

Btw: your dictionary name is wierd and confusing because of that dot. I would change it to studentIds or something ...


Updated based on your edits:

First check this: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#for

I really dont understand exactly what you are after but if you want to access a value from the rows dict based on a key which is equal to a student_id you can try this and see how it works out for you and adjust it to your needs:

{% for student_id, student_id_value in student.ids.items %}
     {{ student_id }}
     {{ rows.student_id }}
{% endfor %}

Solved it this way:

{% for t_id, i_id in teacher_invite_ids.items %}
 {% if t_id == row.4 %}
  {{ i_id }}
 {% endif %}
{% endfor %}

Tags:

Django