3

Please see the following the code:

{% for row in df_src.iterrows %} <tr > <td><input type="checkbox"></td> {% for col in columns %} <td class="redrow">{{row.1.col}}</td> {% endfor %} </tr> {% endfor %} 

Here in {{row.1.col}} where col can be any value like NAME, PHONE, etc. When I access it like {{row.1.PHONE}} I get the value in html, however when I access it like {{row.1.col}} nothing is shown in html.

1
  • The second for loop seems wrong. What's the structure of the row? Commented Apr 25, 2018 at 10:57

1 Answer 1

6

You cannot access it that way, djangos template language does not allow that. See this post that @BearBrown mentioned in his comment.

You could write your own custom template filter like this answer shows:

from django.template.defaulttags import register ... @register.filter def get_item(dictionary, key): return dictionary.get(key) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.