django - 试图让 log_error 装饰器在 Django 中工作,但得到元组错误
问题描述
试图模仿这篇文章中的第一个答案并创建一个 log_error 装饰器: 将所有错误记录到控制台或 Django 站点上的文件
这是我得到的错误:
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
也许我不应该把这个函数放在views.py中,或者这在Django 2.2.3中不起作用?
def log_error(func):
def _call_func(*args, **argd):
try:
func(*args, **argd)
except:
print("error") #substitute your own error handling
return _call_func
解决方案
推荐阅读
- c - 想为此代码创建某种循环
- r - 需要帮助根据第一个数据表中是否存在行来制作具有布尔值的第二个数据表
- python-3.x - 将 Pandas Dataframe 转换为 TensorFlow 数据集,将二维数组作为数据
- reactjs - 反应错误:渲染没有返回任何内容
- android - Android ThreeTen ABP 库在单元测试中不起作用(ZoneRulesException)
- c# - 从二进制文件作为类对象读取
- c# - RuntimeBinderException 与动态对象调用公共静态方法 TryParse
- python - 构建 Flask 应用程序 - sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation)
- javascript - 数据模式一致性检查
- java - 如何使用 Apache POI 创建链接到长 url 的 excel 超链接