Django: manage.py does not print stack trace for errors

情到浓时终转凉″ 提交于 2019-12-18 12:51:38

问题


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__'

(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)

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)

回答1:


Have you tried passing the --traceback argument?

e.g:

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


来源:https://stackoverflow.com/questions/16581572/django-manage-py-does-not-print-stack-trace-for-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!