Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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)
like image 724
RexE Avatar asked May 16 '13 07:05

RexE


People also ask

Why does Python manage PY Runserver not work?

The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

How do you get a stack trace in Python?

Print Stack Trace in Python Using traceback Module The traceback. format_exc() method returns a string that contains the information about exception and stack trace entries from the traceback object. We can use the format_exc() method to print the stack trace with the try and except statements.


1 Answers

Have you tried passing the --traceback argument?

e.g:

python manage.py graph_models --traceback -a -g -o my_project.png
like image 79
tuxcanfly Avatar answered Oct 07 '22 17:10

tuxcanfly