Djangoのtemplateでdictをforで回す方法

127 views
Skip to first unread message

melodeen

unread,
Jan 5, 2010, 9:25:19 PM1/5/10
to django-ja
Djangoのテンプレートで下記のようなdictをforで処理する事は出来るのでしょうか?
listの中身は{"a": "123", "b": "456"}こんな感じです。

for k, v in list.iteritems():

tokibito

unread,
Jan 6, 2010, 1:50:16 AM1/6/10
to django-ja
岡野です。

ドキュメントにもありますが、可能です。
http://djangoproject.jp/doc/ja/1.0/ref/templates/builtins.html#ttag-for

{% for key, value in data.items %}
{{ key }}: {{ value }}
{% endfor %}

melodeen

unread,
Jan 6, 2010, 2:39:44 AM1/6/10
to django-ja
ありがとうございます。

見逃していました。

Reply all
Reply to author
Forward
0 new messages