Trouble accessing dictionary with dot notation in Django Template -


I have a problem using the template language point in my dictionary to reach values ​​

Here is an example of my example:

  {2L: {'dob': datetime.date (2012, 7, 7), 'image': u '', 'user_id': 3 L 'id': 2L, 'email': u'blank@blank.com '}, 3L: {' dob ': datetime.date (2012, 7, 7),' image ': u' ', 'User_id': 4L, 'id': 3L, 'email': u'blank@blank.com '}}   

The way I would use it in Python: / P>

  D [2] ['email']   

My TEM What I have tried in the template is: {% D in D%} {% if d == a.user_id%} {{Ddemail}} {% endif%} {% endfor%} / Pre >

It is not printing anything ... (I have tested that by adding some HTML inside the execution block, My Boolean believes the truth.

Do you help me with the notation here I know this: {{Ddemail}} this is wrong.

Thanks.

you do not want {{Ddemail}} , which is D ['D'] Micro sees. There is no syntax in Django templates to use a variable as a key.

Use it:

  {% d in d, v} {% if d == a.user_id%} {{V.email} } {% Endif%} {% endfor%}    

Comments