I'm starting to learn django and I was wondering what's the best way to debug a django application?
More specifically, I'm looking for a way to print out variables, in an equivalent way to var_dump statements in php.
While running the development server, you can issue print statement that will get printed in the console output. You can also use pdb while handling a request and debug directly.
You could put these statements in your view code:
import pdb; pdb.set_trace()
to enter interactive debug and trace as long as you want or almost.
I can recommend django-extensions runserver_plus
. It includes the super useful werkzeug debugger. Whenever an exception in dev-mode occurs you can view the code that caused the inspection and open a debug console in you browser that gives you full access to a python REPL with all variables at exception time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With