开发者

Debugging Django from the command-line

I'm working on debugging Django from the command-line. I'm working with django_extensions, and I have IPython installed and ideally I'd like to be able to extract as much开发者_Python百科 information in the shell as possible. How would I go about this task most efficiently?


As mentioned by Geo manage.py shell is good but since you have django_extensions already installed then Carl's suggestion of manage.py shell_plus is even better... saves a ton of typing.

But, as a third suggestion that is a bit less general, you might also want to check out django-viewtools. I personally tend to use shell_plus, but this might be useful.


If you have django_extensions installed, use

python manage.py shell_plus

to get all of your model classes automatically pre-loaded.


How about:

python manage.py shell

More info here


My favorite ways of debuging django problems is using the ./manage runserver_plus command to the django_extensions. It uses the Werkzeug debuger, which gives you a python shell in the web browser itself. If you want a shell anywhere in the code, just type some bogus python, like a simple a, and you will get a shell when that code is executed.

Another nice tool is ipdb ipython debugger. Its the same as pdb but better (and uses ipython. With this, and runserver_plus, you can insert import ipdb; ipdb.set_trace(), and you will get a ipython shell with an debugger in the same window as you have runserver_plus. Take a look at http://docs.python.org/library/pdb.html#debugger-commands for a list of commands you can use inside the debugger.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜