Zhang Wei
Zhang Wei

Reputation: 1

django templates variable issue

I got a questions, in Django html templates file, I can use the {{ names }} to get a variable from the views.py via render_to_response(). However, how can I do something like this in the HTML templates:

{{% for name in names %}}
    ...
{{% endfor %}}

I tried to write like

{{% for name in {{ names }} %}}

of course it doesn't work.

anyone could help me on this? thanks.

Upvotes: 0

Views: 175

Answers (1)

Aamir Rind
Aamir Rind

Reputation: 39709

You can iterate over list in a template like this:

{% for name in names %}
    {{ name }}
{% endfor %}

Read more about the for template tag.

Upvotes: 1

Related Questions