I am tryin creating a drop down list to select a year. The list has to goto 200 years in the past starting from today. I am unable to make a loop work in jinja to create the select options.
I have passed it the now
variable which holds current year(2020).
The line now -= 1
is thowing me eror:
jinja2.exceptions.TemplateSyntaxError
<select class = "year" name = "year">
{% for x in range (200) %}
<option value= '{{ now }}'>{{ now }}</option>
{% now -= 1 %}
{% endfor %}
</select>
In php I would do this and it works:
<?php
$curr_date = date('Y');
for ($i = $curr_date; $i > 1800; $i--) {
echo '<option value = "' . $i . '">' . $i . '</option>';
}
?>