后台代码:
fielddict = {'name':'张三','age':18}
return render(request,'test.html',{'field':fielddict})
前端代码:
{% for m,n in field.items %}
{{ m }}:{{ n }}
{% endfor %}
效果图:
如果在前端想根据键取出值:
{{field.name}}
{{field.age}}
后台代码:
fielddict = {'name':'张三','age':18}
return render(request,'test.html',{'field':fielddict})
前端代码:
{% for m,n in field.items %}
{{ m }}:{{ n }}
{% endfor %}
效果图:
如果在前端想根据键取出值:
{{field.name}}
{{field.age}}