how can i debug my django code ?
-
yes i tried that , i was actually looking for something where i can evaluate the values of different variable if and error occurs. – Bunny Rabbit Nov 21 '10 at 12:42
4 Answers
Generally, I use django-debug-toolbar for debugging django-specific stuff.
pdb
is useful for lower-level shell debugging, when you're using runserver
. Though I prefer to use ipython (pip install ipdb
, then import ipdb; ipdb.set_trace()
, like you would with pdb
)
There's also werkzeug
, which, when combined with django-extensions' runserver_plus
command, will allow you to open a web-based python shell on error pages:
This item requires that you have the Werkzeug WSGI utilities (version 0.3) installed. Included with Werkzeug is a kick ass debugger that renders nice debugging tracebacks and adds an AJAX based debugger (which allows to execute code in the context of the traceback’s frames). Additionally it provides a nice access view to the source code.

- 6,805
- 4
- 33
- 39
-
1django_toolbar. This is important. Gives you the ability to read session data, track back variable history - template inheritance. This is a necessity when working with django! – Glycerine Nov 20 '10 at 21:54
-
yes i installed werkzeug but seems like run_server plus won't work with appengine. – Bunny Rabbit Nov 21 '10 at 08:22
What's wrong with the built-in Python debugger? Just insert this in your code where you want to set a breakpoint:
import pdb; pdb.set_trace()
and execution will pause there, and the console will show a debugging prompt enabling you to inspect variables and step through the code.

- 588,541
- 66
- 880
- 895
-
and where i am supposed to see the debugging prompt on the terminal where i am running the server? and how to resume the server ? – Bunny Rabbit Nov 20 '10 at 20:53
-
1
-
2See the full documentation: http://docs.python.org/library/pdb.html#debugger-commands – Daniel Roseman Nov 20 '10 at 21:11
-
Also check out this post and vimeo tutorial on pdb: http://ericholscher.com/blog/2008/aug/31/using-pdb-python-debugger-django-debugging-series-/ – jbaums Nov 21 '10 at 05:08
Get PyCharm from JetBrains. It has a lovely built in debugger and Django support.

- 305,152
- 44
- 369
- 561
I use Aptana Studio and pyDev - and eclipse IDE. its free and has build in django and debugging.

- 7,157
- 4
- 39
- 65