Debugging and dealing with errors
When programming, unless you’re the perfect programmer who never makes mistakes, you’ll probably have to deal with errors or debug your code at some point. When there is an error in your program, there are usually two ways to tell – either your code will raise an exception, or you will get unexpected output or results when viewing the page. You will probably see exceptions more often, as there are many accidental ways to cause them. If your code is generating unexpected output but not raising any exceptions, you will probably want to use the PyCharm debugger to find out why.
We’ll start with an overview of some Python exceptions and how to handle them, along with an exercise that demonstrates how Django shows exceptions. Then, we’ll look at running Django inside the PyCharm debugger so that you can peek inside your program while it executes.
Exceptions
If you have worked with Python or other programming languages...