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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With