Monday, April 25, 2011

Best Django debugging technique ever

Start up your test app using the Development Server. Then inject the following into your code where you want to examine everything, perhaps in an exception handler.


import pdb
pdb.set_trace


Now when you hit the exception, pdb will take over the console window you started the test app. Type help if you are unfamiliar with pdb. All of your variables are available for review!

Sweet! I can't believe I didn't know about this technique before.

No comments: