Django template language dictionaries Django template language circulation loop dictionary

Django template language dictionaries cycle

1. For the dictionary, you can use the following:

{% for row in user_dict.keys %}
{% for row in user_dict.values %}
{% For row in user_dict.items%} tuples to give

{% for k,row in user_dict.items %}
  <li>{{k}}-{{row}}</li>
{% endfor %}

2. views.py中程序


Procedures and operating results:


 
 



1. For the dictionary, you can use the following:

{% for row in user_dict.keys %}
{% for row in user_dict.values %}
{% For row in user_dict.items%} tuples to give

{% for k,row in user_dict.items %}
  <li>{{k}}-{{row}}</li>
{% endfor %}

2. views.py中程序


Procedures and operating results:


 



Guess you like

Origin www.cnblogs.com/ajaxa/p/11778098.html