【发布时间】:2016-04-14 22:52:00
【问题描述】:
我正在尝试将 JSON 加载到 Django 模板中,这很顺利。但我得到 [] 围绕它和 'u 在它之前。我想知道是否有什么我可以做的。这是我使用的代码:
json_response = requests.get(endpoint + "appointments?user="+user+"&access_token="+token+"&start="+str(int(timestamp_start))+"&end="+str(int(timestamp_end))+"&valid=true").json()
appointmentsVrijdag = json_response['response']['data']
return render(request, template, {"appointmentsVrijdag": appointmentsVrijdag})
然后,要在模板中加载它,我使用以下代码:
{% for appointment in appointmentsVrijdag %}
{% if appointment.cancelled != True %}
<tr>
<td>
{{ appointment.teachers }}
{{ appointment.subjects }}
</td>
</tr>
{% endif %}
{% endfor %}
我希望得到一些帮助!
【问题讨论】:
标签: python html json django django-templates