Found "How to debug django webapp with autoreload" . That was a smart hack to hook into the autoreload mechanism to set up pydevd.settrace. Its a real pain without that to put in a
import pydevd pydevd.settrace()
in all places that you want to debug. With an IDE, you should be able to setup a breakpoint, hit the code , let it stop where you set the breakpoint and move on.
The post above indicated how things probably worked for Django pre 1.0 and dint work for me with the 1.1 codebase, Here is the modified code for manage.py that worked with Django 1.1
command = None if len(sys.argv) != 1: command = sys.argv if settings.DEBUG and (command == 'runserver' or command == 'testserver'): try: import pydevd inEclipse = True except ImportError: inEclipse = False if inEclipse: from django.utils import autoreload m = autoreload.main def main(main_func): import os if os.environ.get("RUN_MAIN") == 'true': def pydevdDecorator(func): def wrap(*args, **kws): pydevd.settrace(suspend = False) return func() return wrap main_func = pydevdDecorator(main_func) return m(main_func) autoreload.main = main
Placing the above code in manage.py after importing the "settings" module seems to allow debugging with autoreload option on.
I also added some logic to check if Im running in Eclipse or not. I dont use Eclipse when Im not using my laptop -- vim is my friend. Its not a robust check, but works to check if we are in Eclipse or not. The idea is to not go into the auto-debug block if you are not running in Eclipse (for e.g. when you are running with vim and a command line).