user2252421
user2252421

Reputation: 1

List like parameter in django template. Is it possible?

Is there any possibility to send a list or a tuple like a parameter to this function:

self.response.out.write(template.render(self.path, sendingList))

i'm new to this and i heard that you can send only dictionary. Is it true?

Upvotes: 0

Views: 75

Answers (1)

Greg
Greg

Reputation: 10360

you can only pass a dict, but items in that dict can be lists:

self.response.out.write(template.render(self.path, {'numbers': [1,2,3,4,5,6]}))

which you can then access in your template with {{ numbers}}, and iterate over it with

{% for number in numbers%}{{ number}}{% endfor %}

Upvotes: 1

Related Questions