我在问有关我的HTML模板的问题。我用Django显示了一些QuerySet的结果,我想修改显示用户方面。
我不知道我是否可以用Django来做这种事情,或者JavaScript是否可以做到这一点。
我有一个HTML模板:
<h2 align="center"> Affichage de toutes les fiches individuelles </align> </h2>
<br></br>
{% block content %}
<h4> Récapitulatif des 10 dernières fiches individuelles créées: </h4>
<ul>
{% for item in identity %}
<li>{{ item }}</li>
{% endfor %}
</ul>
<h4> Récapitulatif des 10 dernières fiches individuelles créées habitant en France: </h4>
<ul>
{% for item in identity_France %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endblock %}
从这个角度来看:
def Consultation(request) :
identity = Identity.objects.all().order_by("-id")[:10] #Les 10 dernières fiches créées
identity_France = Identity.objects.filter(country='64').order_by("-id")[:10] #Les 10 dernières fiches où la personne habite en France
context = {
"identity" : identity,
"identity_France" : identity_France,
}
return render(request, 'resume.html', context)
是否可以将结果显示为数组?带有列,每列的标签等...?
像这样的东西:
谢谢 !
编辑 :
我发现JQuery可以做到这一点:JQuery数组
您可以在{%for%} {%endfor%}模板标签内执行任何操作。例如,您可以将对象放在桌子内
<table>
<thead>
<tr>
<th>Field 1 Name</th>
<th>Field 2 Name</th>
</tr>
</thead>
<tbody>
{% for item in identity_France %}
<tr>
<td>{{ item.field1 }}</td>
<td>{{ item.field2 }}</td>
<tr>
{% endfor %}
<tbody>
</table>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句