删除django模板中的[u'']

时间:2016-01-10 16:24:36

标签: python html json django django-templates


我正在尝试将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 %}

我希望得到一些帮助!

1 个答案:

答案 0 :(得分:4)

假设@Entity(name="DBAssembly") @Table(name="DBAssembly",catalog="lag",schema="public") appointment.teachers是列表,您可以使用built-in join filter加入模板中的项目:

appointment.subjects