views:

21

answers:

1

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

Example

model=MyModel.object.all()

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

How it'll looks in template?

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

+1  A: 
{% for each_model in model %}
    #Do Something with model
    {{each_model.name}}
{% endfor %}
Lakshman Prasad
Thanks man. I knew that it'll be simple.
Pol
Can I show field of foreigne key object in this template?
Pol
@Pol - Sure. `{{ each_model.someForeignKey.someField }}`
Yuval A