0
查询后的每个结果被我的收藏命名为“患者”在MongoDB中执行:我有这样的代码,结果名为patient_doc
:查看与神社查询,蟒蛇
{ "_id" : "5576ee2e1a6d6d0d9b879095", "date_of_birth" : "29/06/2015", "diagnosis" : "Mamografia", "doctor_id" : "554b6e791a6d6d34cc3272f7", "name" : "Xona", "sex" : "Female", "surname" : "Krasniqi" }
{ "_id" : "5576ee2e1a6d6d0d9b879095", "date_of_birth" : "29/06/2015", "diagnosis" : "Ekografia", "doctor_id" : "554b6e791a6d6d34cc3272f7", "name" : "John", "sex" : "Male", "surname" : "Esma" }
我渲染包含表格的模板:
return render_template('patient-record.html', patient_doc=doc)
在浏览器中,我只显示一个患者,我如何使用jinja语法来查看所有结果。我的意思是我怎么可以做一个循环来显示我病例中每个病人的数据。我试过{% for patient_doc in patient_doc %}
但没有结果。
HTML文件命名为患者record.html包含此代码:
<table class="patient-view-table">
<tr>
<td class="property-name-col">Name:</td>
<td class="property-value-col">{{ patient_doc.name }}</td>
</tr>
<tr>
<td class="property-name-col">Surname:</td>
<td class="property-value-col">{{ patient_doc.surname }}</td>
</tr>
<tr>
<td class="property-name-col">Sex:</td>
<td class="property-value-col">{{ patient_doc.sex }}</td>
</tr>
<tr>
<td class="property-name-col">Date of birth:</td>
<td class="property-value-col">{{patient_doc.date_of_birth}}
</td>
</tr>
<tr>
<td class="property-name-col">Diagnosis:</td>
<td class="property-value-col">{{ patient_doc.diagnosis }}</td>
</tr>
</table>
任何机构可以帮我解决这个问题?
@VictorLean首先感谢您的回答。我想要一些动态的东西,因为我可以添加和删除患者,然后如果我添加例如100位患者,我该如何做100张桌子? – Babel
@Egzona刚刚编辑过这个例子,只需使用'''''和''
'''标记。 –@Egzona你见过更新的代码吗? –
相关问题