Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass QuerySet object in template. Django

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

Example

queryset =MyModel.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?

like image 970
Pol Avatar asked Jul 20 '10 15:07

Pol


1 Answers

{% for each_model in model %}
    #Do Something with model
    {{each_model.name}}
{% endfor %}
like image 92
lprsd Avatar answered Oct 13 '22 20:10

lprsd