我可以在Django中调用werkzeug调试器,而不需要引发异常或使用断言? [英] Can I call the werkzeug debugger in Django without needing to raise an exception or using assertions?

查看:429
本文介绍了我可以在Django中调用werkzeug调试器,而不需要引发异常或使用断言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 Werkzeug 连同 django-extensions ,我可以调用 werkzeug 调试器通过引发异常或产生错误的断言。可以设置 werkzeug 的断点,如 import pdb; pdb.set_trace()是吗?

I'm currently using Werkzeug together with django-extensions and I'm able to call the werkzeug debugger by raising an exception or making a false assertion. Is it possible to just set a breakpoint for werkzeug like import pdb; pdb.set_trace() does?

推荐答案

如果您使用Apache / mod_wsgi,要做的是修改你的.wsgi文件以包括:

If you are using Apache/mod_wsgi, all you need to do is modify your .wsgi file to include:

from werkzeug.debug import DebuggedApplication

application = get_wsgi_application()
application = DebuggedApplication(application, evalex=True)

然后你可以访问python shell在example.com/console(注意控制台之后的空间!)

Then you can access the python shell at "example.com/console " (Note the space after console!)

这篇关于我可以在Django中调用werkzeug调试器,而不需要引发异常或使用断言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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