简体   繁体   English

当我的DEBUG = False时,Django怎么不给我发错误?

[英]How come Django doesn't email me errors when my DEBUG = False?

ADMINS = [("alex", "alex@mydomain.com"), ("matt", "matt@mydomain.com")]

DEBUG = False

How come Django doesn't email me errors? 为什么Django不会给我发错误? I set up the email settings correctly, and everything else can send email just fine. 我正确设置了电子邮件设置,其他所有内容都可以发送电子邮件。

EMAIL_HOST = "mail.blah.com"
EMAIL_PORT = 25
EMAIL_HOST_USER = "blah"
EMAIL_HOST_PASSWORD = "blah"
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = "blah@blah.com"

I want to be emailed all errors that occurred. 我希望通过电子邮件发送所有发生的错误。 (even though I have my own try /except blocks everywhere). (尽管我到处都有自己的尝试/除了块)。

From django documentation on error-reporting : 来自关于错误报告的 django文档:

By default, Django will send e-mail from root@localhost. 默认情况下,Django将从root @ localhost发送电子邮件。 However, some mail providers reject all e-mail from this address. 但是,某些邮件提供商拒绝来自此地址的所有电子邮件。 To use a different sender address, modify the SERVER_EMAIL setting. 要使用其他发件人地址,请修改SERVER_EMAIL设置。

Maybe this will help you. 也许这会对你有所帮助。

One thing I've found that helps me debug the email subsystem in django is a setup that displays the email content (headers and all) to standard out. 我发现有一件事可以帮助我调试django中的电子邮件子系统是一个设置,显示标准输出的电子邮件内容(标题和所有)。 I've summarized below, but you can also find more info about in the django documentation (link below). 我在下面总结了一下,但您也可以在django文档中找到更多信息(链接如下)。 Not sure if it will help you in your case, but it might help debug the issue ... help you see what's being sent. 不确定它是否会对您的情况有所帮助,但它可能有助于调试问题...帮助您查看正在发送的内容。

Set the following in settings.py 在settings.py中设置以下内容

EMAIL_HOST = "localhost"
EMAIL_PORT = 1025

Run the following to host the test webserver 运行以下命令以托管测试Web服务器

python -m smtpd -n -c DebuggingServer localhost:1025

Django documentation: http://docs.djangoproject.com/en/dev/topics/email/ Django文档: http//docs.djangoproject.com/en/dev/topics/email/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM