如何查看Django视图的错误日志

时间:2022-10-07 09:57:09

I'm coding a small application with Django. But I can't see any error logs in the console when an error (e.g. Python syntax error, etc.) occurs in one of my views -no action at all.

我正在用Django编写一个小应用程序。但是当我的一个视图中出现错误(例如Python语法错误等)时,我无法在控制台中看到任何错误日志 - 根本没有动作。

How can I see the error logs of my views? Debugging like a blind is really annoying.

如何查看我的观点的错误日志?像盲人一样调试真的很烦人。

1 个解决方案

#1


5  

Django does not print any errors to the console by default. Instead it provides very helpful error pages that are displayed for any errors that occur in your views. Please check what your DEBUG setting is set to. In development this should be True which will give you the nice error pages for 404 and 500 errors.

默认情况下,Django不会向控制台输出任何错误。相反,它提供了非常有用的错误页面,可以显示在视图中发生的任何错误。请检查您的DEBUG设置是什么。在开发中,这应该是True,这将为您提供404和500错误的错误页面。

The pretty error page will look like this: django error page http://linkaider.com/wp-content/uploads/2009/12/django-error.jpg

漂亮的错误页面如下所示:django错误页面http://linkaider.com/wp-content/uploads/2009/12/django-error.jpg

I can also recommend the talk What the Heck Went Wrong? from DjangoCon2009 for some more information on basic debugging technics with django.

我还可以推荐一下他妈的错了什么?从DjangoCon2009获取有关django基本调试技术的更多信息。

#1


5  

Django does not print any errors to the console by default. Instead it provides very helpful error pages that are displayed for any errors that occur in your views. Please check what your DEBUG setting is set to. In development this should be True which will give you the nice error pages for 404 and 500 errors.

默认情况下,Django不会向控制台输出任何错误。相反,它提供了非常有用的错误页面,可以显示在视图中发生的任何错误。请检查您的DEBUG设置是什么。在开发中,这应该是True,这将为您提供404和500错误的错误页面。

The pretty error page will look like this: django error page http://linkaider.com/wp-content/uploads/2009/12/django-error.jpg

漂亮的错误页面如下所示:django错误页面http://linkaider.com/wp-content/uploads/2009/12/django-error.jpg

I can also recommend the talk What the Heck Went Wrong? from DjangoCon2009 for some more information on basic debugging technics with django.

我还可以推荐一下他妈的错了什么?从DjangoCon2009获取有关django基本调试技术的更多信息。