Django:manage.py不会打印堆栈跟踪的错误 [英] Django: manage.py does not print stack trace for errors

查看:446
本文介绍了Django:manage.py不会打印堆栈跟踪的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Django中,大多数时候,当我运行 manage.py 并且遇到错误时,我没有得到错误的完整堆栈跟踪,只是异常的文本,使其很难调试。示例:

In Django, most of the time when I run manage.py and it encounters an error, I don't get the full stack trace for the error, just the text of the exception, making it very hard to debug. Example:

python manage.py graph_models -a -g -o my_project.png
AttributeError: 'str' object has no attribute '__module__'

(这是为graph_models加载项,但它也发生内置命令,唯一的例外是 runserver ,遇到与其他命令相同的错误,但打印完整的堆栈跟踪)

(This is for the graph_models add-on, but it also occurs for built in commands. The only exception I found is runserver, which encounters the same errors as the other commands but prints the full stack trace)

这是我的manage.py文件。我的项目最初是为Django 1.1创建的,但我最近升级到1.5。

Here is my manage.py file. My project was originally created for Django 1.1, but I recently upgraded to 1.5.

#!/usr/bin/env python
import os, sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ctree.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)


推荐答案

您是否尝试传递 - 追溯参数?

例如:

python manage.py graph_models --traceback -a -g -o my_project.png

这篇关于Django:manage.py不会打印堆栈跟踪的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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