Tracking internal code state
Sometimes even all of the information available from a tool like the Django Debug Toolbar is not enough to figure out what is going wrong to produce incorrect results during processing of a request. The problem probably lies somewhere in the application code, but from visual inspection we just cannot figure out what is wrong. To solve the problem we need to get more information about the internal state of the application code. Perhaps we need to see what the flow of control is through the functions in the application, or see what values are calculated for some intermediate results that ultimately cause the code to go down a wrong path.
How do we get this kind of information? One way is to run the code under a debugger, and actually step through it line by line to see what it is doing. This approach will be covered in detail in the next chapter. It is very powerful, but can be time-consuming and is not practical in all situations. For example, it is difficult to...