Django中字典在html中的遍历

如:在view中定义的函数

info = {'xiaofang': '18', 'xiaoming': '20'}
context = {"info": info}

 

要在html中变量出info的信息(注意info.items,千万不能漏了items)

{% for info_name,info_age in info.items %}
    {{ info_name }}
    {{ info_age }}
{% endfor %}

 

相关文章:

  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
相关资源
相似解决方案