Debugging Django with PyDev
April 21, 2010
To debug a Django app within Eclipse, you need to start manage.py
with the runserver
parameter from within eclipse. You also need the --noreload
parameter or else the debugger may end up attached to the wrong process.
Steps
- Find manage.py in your source.
- Right click it, and Debug as.../Debug Configurations
- On the arguments tab, put
runserver --noreload
in the Program arguments box - Click debug
You should at this point see the familiar output in the console inside Eclipse:
pydev debugger: starting Validating models... 0 errors found Django version 1.0.2 final, using settings 'dcsweb.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK.
I had problems with something else running on port 8000, so I modified my parameters to be runserver 8001 --noreload
so I was running on port 8001.
You can now set breakpoints in the code, and execution will stop when it hits them.