如何将请求包含在Django的生产站点的追溯邮件中 [英] How can I include the request.User details in Django's traceback email for a production site
本文介绍了如何将请求包含在Django的生产站点的追溯邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在发生错误时通过电子邮件发送到站点管理员的上下文详细信息以及追溯和请求中包含request.user的内容.GET / POST / COOKIES / META
I would like to include the contents of request.user in the context details emailed to the site admins when an error occurs, as well as the traceback and request.GET/POST/COOKIES/META
任何帮助赞赏
推荐答案
由于process_exception中间件传递了请求对象,您可以添加任何你想要的信息.META
Because process_exception middleware gets passed the request object, you can add whatever info you like to request.META
class ErrorMiddleware(object):
"""
Alter HttpRequest objects on Error
"""
def process_exception(self, request, exception):
"""
Add user details.
"""
request.META['USER'] = request.user.username
这篇关于如何将请求包含在Django的生产站点的追溯邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文