Show undefined variable errors in Django templates?

后端 未结 8 903
长情又很酷
长情又很酷 2020-12-24 08:50

How can I ask Django to tell me when it encounters, for example, an undefined variable error while it\'s rendering templates?

I\'ve tried the obvious DEBUG = T

8条回答
  •  误落风尘
    2020-12-24 09:05

    Read up on how invalid variable are handled in templates. Basically, just set TEMPLATE_STRING_IF_INVALID to something in your settings.py.

    TEMPLATE_STRING_IF_INVALID = "He's dead Jim! [%s]"
    

提交回复
热议问题