I know for a while how to trace code with pdb, but I used to use the famous
import pdb;pdb.set_trace()
which enable debugging when this line is reached.
However, I’ve had an exception raised by django when saving an object :
File "/opt/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.5... return int(value) ValueError: invalid literal for int() with base 10: ''
and it’s totally anoying to trace the save() function step by step. After looking at pdb doc, I’ve found what I was looking for : the post_mortem() method :
try:
object.save()
except:
import pdb;pdb.post_mortem()
this runs pdb where the exception is raised, and then allows me to see which is that field on my model which is not properly set.