Debugging Python code in a browser with wdb debugger
Handy and universal Python debugger available for Django and other Python application
wdb is a nice Python debugger running as a server and capable of launching debug session in your browser. It can handle simple scripts, web apps (Tornado, Flask or Django based and alike) as well as other multithread and multiprocess programs. It's easy to use and not much configuration is required.
The serverInstall it:
DebugginBasic script can be debugged like this:
On the right side we have the stacktrace, on the left the debugged Python code, and below it - an interactive Python console. Aside of Python code it also supports debugger commands, like .s will tell the debugger to move to next break-point (or next line in this case).
Debugging Django or other applications you will want to use breakpoints - a places in code at which execution should stop launching the debug session. To create them for wdb just import it and then place in the code:
DjangoOne of wdb usages is to debug Django applications. To do that some configuration is needed. At first in wsgi.py find: And add after it: In settings.py add: And that's it.
There are IDEs like PyCharm that have their own debuggers. They offer similar or equal set of features. You also don't have to modify the code to set breakpoints or to start debugging. However to use them you have to use those specific IDEs (and some of then are non-free or may not be available for all platforms). Pick the right tool for your needs.