[英]removing [u''] in the django template
我正在嘗試將JSON加載到Django模板中,並且進展順利。 但是我繞過它,而在它之前。 我想知道是否有什么我可以做的。 這是我使用的代碼:
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 %}
我希望得到一些幫助!
假設appointment.teachers
或appointment.subjects
是列表,您可以使用內置的join
過濾器將模板中的項目連接在一起:
{{ appointment.teachers|join:", " }}
{{ appointment.subjects|join:", " }}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.