chiggsy
chiggsy

Reputation: 8433

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 information in the shell as possible. How would I go about this task most efficiently?

Upvotes: 4

Views: 8707

Answers (4)

xeor
xeor

Reputation: 5455

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.

Upvotes: 1

Van Gale
Van Gale

Reputation: 43912

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.

Upvotes: 3

Carl Meyer
Carl Meyer

Reputation: 126591

If you have django_extensions installed, use

python manage.py shell_plus

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

Upvotes: 2

Geo
Geo

Reputation: 96827

How about:

python manage.py shell

More info here

Upvotes: 1

Related Questions