Debugging Django Shell with PyDev on Eclipse

If you are using PyDev on Eclipse for developing a Django based App. You might already know that PyDev provides support for debugging Django Apps, by running a test server on the localhost and port  8000 by default.

If you haven’t done that before you will be happy to know that It is very easy to enable Django support of an existing PyDev project (details here). Or if you are an absolute beginner, you might find this video helpful: https://vimeo.com/5027645

For quick debugging while working on a new feature, many developer prefer to run the App in the Django Shell mode. Something i resort to every now and then, especially when encountering illusive bugs.

Sadly there is no out-of-the box debugging Django Shell support by PyDev, and by that, i mean that there is no obvious way to debug Django Shell using PyDev; there is no shortcut for it.

However there is a trivial not so obvious way to achieve that.

  • From the “Run” menu chose “Debug Configuration…”
  • Find Django configuration of your project
  • Right click to duplicate it
  • Rename the configuration (if you want)
  • From the “Arguments” tab replace the argument “runserver” with “shell”.
  • Save the configuration by clicking on Apply
  • Now you can use the new configuration to debug the Django Shell of your App.

That’s it!

 

Leave a Reply