Pol*_*Pol 5 python django-templates
如何将QuerySet对象传递给模板.然后在tempalte中迭代它.如果ican这样做....?
例
queryset =MyModel.objects.all()
return render_to_response('template.html',{'queryset':queryset})
Run Code Online (Sandbox Code Playgroud)
它在模板中看起来如何?
我可以在此模板中显示foreigne key object的字段吗?
{% for each_model in model %}
#Do Something with model
{{each_model.name}}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7634 次 |
| 最近记录: |