Handling an undefined template variable in Tornado

后端 未结 4 973
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:34

    {% if locals().get('logout_error', False) %} not works because variables not passed as in **kwargs;

    {% if globals().has_key('logout_error') %} works to me because my variables are passed separately, https://groups.google.com/forum/#!topic/python-tornado/dyl50NO3yzE this page has more disscussion on this problem.

提交回复
热议问题