Python 如何在Jinja2中设置/获取变量
我不明白,为什么这个代码不起作用:Python 如何在Jinja2中设置/获取变量,python,jinja2,conditional-statements,Python,Jinja2,Conditional Statements,我不明白,为什么这个代码不起作用: {% set t_c = 'param_1' %} <div class="col-sm-9"> <select id="category" name="category" class="form-control " required> <option></option>
{% set t_c = 'param_1' %}
<div class="col-sm-9">
<select id="category" name="category" class="form-control " required>
<option></option>
{% for c in categories %}
{% if c.id|string == org.category.id %}
{% set t_c = 'param9' %}
<option value="{{ c.id }}" selected>{{ c.name }} </option>
{% else %}
<option value="{{ c.id }}">{{ c.name }} </option>
{% endif %}
{% endfor %}
</select>
</div>
<input id="category_h" name="category_h" type="hidden" value="{{ t_c }}">
t_c='param9'
有
var category = $("#category"),
category_h = $("#category_h");
category.select2();
category_h.val(category.find("option:selected").text());