如何查看Django视图的错误日志 [英] How can I see error logs of Django views

查看:206
本文介绍了如何查看Django视图的错误日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我如何看到我的意见的错误日志?

解决方案

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



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



我也可以推荐一下 Heck Went错误? 从DjangoCon2009为有关django的基本调试技术的更多信息。


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.

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

解决方案

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.

The pretty error page will look like this: django error page 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.

这篇关于如何查看Django视图的错误日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆