Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django step through the code

is it possible to to a step through the code in django ( i mean step through while debugging)

like image 248
Bunny Rabbit Avatar asked Apr 07 '26 02:04

Bunny Rabbit


2 Answers

Yes, you can do that by using the Python Debugger module, pdb. I have covered the topic of debugging Django applications on my blog before. In an nutshell, if you are using the Django development server, you can easily step through your Django application by placing a breakpoint with the statements import pdb; pdb.set_trace() at any point in your view code where you want to start debugging, and then step through the debugger that is invoked on the shell where the Django development server was running from.

like image 129
ayaz Avatar answered Apr 10 '26 02:04

ayaz


Yes, as long as you're running in the development server.

If so, just put this into your code at the point you want to stop:

import pdb; pdb.set_trace()

and you will be dumped into the debugger on the console, from where you can step through to your heart's content.

like image 32
Daniel Roseman Avatar answered Apr 10 '26 02:04

Daniel Roseman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!