我正在尝试for
在我的模板中编写一个循环,如此处所述。
视图.py:
def simple_view(self, request):
adictionary = {'first': 'this is the first value',
'second': 'this is the second value',
'third': 'this is the third value'}
return render_to_response("index.html",
{'adictionary': adictionary},
context_instance=RequestContext(request))
索引.html:
{% for key, value in adictionary %}
{{ key }} : {{ value }} <br/>
{% endfor %}
这是我对 HTML 输出的期望:
first : this is the first value
second : this is the second value
third : this is the third value
这就是我得到的:
s : e
t : h
f : i
这对你有意义吗?我要砸键盘了。