Remote debugging - debugging pesky server only bugs

By : Shabda Raaj

Here is a quick tip. (Obvious if you work with Django for any length of time, but I have seen a few people who are not aware)

You can put debug trace import pdb; pdb.set_trace() in your code, and put it on the server. When you access this view from your local browser, the debug is still hit and you have a debug shell on your server where you can step through. (Obviously this works only if you ran the code via runserver. But runserver start the server to listen only on local connections. If you want to access remotely you need to run as,

python runserver

Edit: As SmileyChris commented, a faster way is,

python runserver 0:8000

The implies that remote connections are possible.

For me, this has been a lifesaver against those pesky bugs which show themselves only on the server, but not on the local machine.

Related Posts

Can we help you build amazing apps? Contact us today.

Topics : django tips
© Agiliq, 2009-2012