4

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?

4 Answers 4

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the viewtools link... I'll be checking it out very soon. Best answer, especially since you read my question. Thanks.
2

If you have django_extensions installed, use

python manage.py shell_plus

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

1 Comment

Shell_plus is great. Also be sure to checkout iPython which adds a lot of useful features when using the shell (like printing dictionaries in 'pretty' tabbed and readable way instead of a clobber of data) -- ipython.scipy.org/moin
1

How about:

python manage.py shell

More info here

1 Comment

Yes, knew about that from the docs. I'd probably go with shell_plus, since I'm already using django extensions.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.