Я хочу проверить тип переменной в Jinja2. Если тип переменной - словарь, тогда я должен напечатать некоторый текст в абзаце, а если он не является точным, тогда я должен напечатать некоторые другие значения.
То, что я пробовал здесь, это
{% if {{result}} is dict %}
<tr>
<td>
<p> The details are not here </p>
</td>
</tr>
{% else %}
{% for each_value in result %}
<tr>
<td>each_value.student_name</td>
</tr>
{% endfor %}
{% endif %}
В результате я получаю два разных способа, один из которых имеет тип dict
I.result={'student_name':'a','student_id':1,'student_email':'my_name@gmail.com'}
другой формат результата:
II.result=[{'student_name':'b','student_id':2,'student_email':'my_nameb@gmail.com','time':[{'st':1,'et':2},{'st':3,'et':4}]}]
Expected result
If I get the format 'I' then the if loop should get execute.
If I get the format 'II' then the else loop should get execute.
Actual result
jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'