如何使一个变量在jijna2默认为“”如果对象是None而不是这样做?
{% if p %}
{{ p.User['first_name']}}
{% else %}
NONE
{%endif %}
所以如果对象p是None,我想默认值p (first_name和last_name)为“”。 基本上
nvl(p.User[first_name'], "")
错误接收:
Error: jinja2.exceptions.UndefinedError
UndefinedError: 'None' has no attribute 'User'