如何在模板中解析变量'未知'时调试"异常"?

epa*_*alm 8 python django django-templates

我一直在看

DEBUG Exception while resolving variable 'exception_type' in template 'unknown'.
Run Code Online (Sandbox Code Playgroud)

在我的django日志中,然后是

VariableDoesNotExist: Failed lookup for key [exception_type] in
Run Code Online (Sandbox Code Playgroud)

接下来看起来像包含请求的字典列表的字符串表示,以及我的整个settings.py文件.

另一个例子:

DEBUG Exception while resolving variable 'lastframe' in template 'unknown'
Run Code Online (Sandbox Code Playgroud)

我觉得我没有足够的信息来调试这个.我所知道的是有一个exception_type在未知模板中调用的变量.我的代码在任何地方都不包含字符串'exception_type'.

我该怎么调试呢?我应该在哪里看?

  • Ubuntu 14.04
  • Python 2.7.6
  • Django 1.11

小智 0

重点不是变量lastframe或变量,exception_type你必须检查你的 url,所有的 url,不仅仅是后端 url,还有前端 url。检查前端 url 和中间件(如果您编写自己的中间件文件,最好的检查方法是在您的 url 上测试 admin)。我也遇到了同样的问题,当我检查 url 和中间件时,我很容易解决了这个问题。