Handling an undefined template variable in Tornado

后端 未结 4 881
Happy的楠姐
Happy的楠姐 2021-02-05 13:59

This is a tornado template (say, in the file logout.html) I render on an error in the logout process:

  {% if logout_error %}
    Oops! The logout failed. Please         


        
4条回答
  •  盖世英雄少女心
    2021-02-05 14:15

    You can use

    {% if locals().get('logout_error', False) %}
    

    Substitute False with the value you want if the property is not set.

提交回复
热议问题