开发者

Pass QuerySet object in template. Django

开发者 https://www.devze.com 2023-01-08 06:42 出处:网络
How can i pass QuerySet object in to template. And then Iterate through it in tempalte. If ican do it....?

How can i pass QuerySet object in to template. And then Iterate through it in tempalte. If ican do it....?

Example

queryset =MyModel开发者_C百科.objects.all()

return render_to_response('template.html',{'queryset':queryset})

How it'll looks in template?

Can I show field of foreigne key object in this template?


{% for each_model in model %}
    #Do Something with model
    {{each_model.name}}
{% endfor %}
0

精彩评论

暂无评论...
验证码 换一张
取 消