T
T
Tyrion Lannister2017-01-12 18:29:15
Django
Tyrion Lannister, 2017-01-12 18:29:15

How to take key value in Django templating language?

{{month[article.date.month]}}
month is a dictionary passed to the template. The month keys are of type int. I need to get month values ​​by key in template. The key is article.date.month of type int. I can’t immediately transfer it in the view (views) before sending it to the template, since this is a piece of code from the loop (the keys are sorted out).
I will be glad for any help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2017-01-12
@sim3x

?

{% for key, val in month.article.date.month.items %}
{{ key }} {{ val }}
{% endfor %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question