2

how can i debug my django code ?

Bunny Rabbit
  • 8,213
  • 16
  • 66
  • 106
  • 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 Answers4

5

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.

eternicode
  • 6,805
  • 4
  • 33
  • 39
  • 1
    django_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
4

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.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
3

Get PyCharm from JetBrains. It has a lovely built in debugger and Django support.

duffymo
  • 305,152
  • 44
  • 369
  • 561
3

I use Aptana Studio and pyDev - and eclipse IDE. its free and has build in django and debugging.

http://www.aptana.com/

Glycerine
  • 7,157
  • 4
  • 39
  • 65