Hacker News new | ask | show | jobs
by Newky 4586 days ago
You are right that this is not straight forward in Django.

There are a number of different routes in Django development that you may need to debug:

1. Debugging view endpoints when not using runserver (for example when testing out your actual deploy webserver). For this, none the debuggers will work, as you have no console to run through. I combat this by using winpdb that allows remote debugging.

2. Debugging either unittest based code or when using runserver, you can use the method described by hcarvalhoalves comment.

However, I still think that in lots of cases its more powerful to import in the code. With the necessary coverage in tests, it should always be picked up.

1 comments

    $ python -m pdb manage.py test
        (Pdb) break mymodule/myfile.py:42
        (Pdb) c
The above should work for tests if I understand correctly, though I haven't checked yet. This solves most of my current debugging problems, and if I'm reading correctly that would solve yours too?

I wonder if you could also use it with runfcgi or any of the other manage commands? I personally use nginx+gunicorn, but for testing production I could switch it to runfcgi or similar really quick.

To be honest though, I don't find myself ever debugging production.