Python 如何解析json数据并将其加载到django模板
我如何解析它以将存储地址id和标题从api加载到select选项值 到目前为止我都试过了Python 如何解析json数据并将其加载到django模板,python,json,django,api,parsing,Python,Json,Django,Api,Parsing,我如何解析它以将存储地址id和标题从api加载到select选项值 到目前为止我都试过了 <select> {% for store in stores.store_address %} <option value="{{ store.store_address.id}}">{{ store.store_address.title}}</option> {% endfor %} </
<select>
{% for store in stores.store_address %}
<option value="{{ store.store_address.id}}">{{ store.store_address.title}}</option>
{% endfor %}
</select>
URL:(json数据)
模板:
<select>
{% for store in stores.store_address %}
<option value="{{ store.store_address.id}}">{{ store.store_address.title}}</option>
{% endfor %}
</select>
{stores.store_address%}
{{store.store_address.title}
{%endfor%}
将模板更改为
演示:
<select>
{% for store in stores %}
{% for store_addres in stores.store_address %}
<option value="{{ store_addres.id}}">{{ store_addres.title}}</option>
{% endfor %}
{% endfor %}
</select>
{%用于存储区中的存储区%}
{存储区中的存储区地址为%。存储区地址为%}
{{store_addres.title}
{%endfor%}
{%endfor%}
注意:
<select>
{% for store in stores %}
{% for store_addres in stores.store_address %}
<option value="{{ store_addres.id}}">{{ store_addres.title}}</option>
{% endfor %}
{% endfor %}
</select>
是一个列表,您需要迭代它,然后访问stores
李>store\u address