[Django]-Debugging Django Forms validation errors


You really should learn how to use debugger with Django and it’s built in server- it has saved me lot’s of print/dir expressions and endless edit-run-observe output-edit iterations.

The most basic way to debug python applications is by using pdb
It’s as easy as dropping in these two lines of code:

import pdb

in that part of code you want to debug. As soon as the second line is executed, program execution stops at that point and you have to switch to console and you can observe the state and contents of variables, execute next line, go to next breakpoint and so on. Just type ? and press enter.
Of course, if you use sophisticated enough IDE debugging is much more easier than this, but this should get you a general idea of how to use debugger.


Leave a comment