How can I look up Django functions?
9th February 2012
My answer to How can I look up Django functions? on Quora
You can use the ./manage.py shell command to get a shell which will import any Django modules (or any of your own code) without complaining about the location of the settings.py module. Install IPython first to get a much more useful interactive shell when you run that command.
Once you’ve done that, “from django.http import HttpResponse; help(HttpResponse)” should work as you would expect. I do most of my Django development interactively.
You can also drop the line “import pdb; pdb.set_trace()” in to any of your view functions when working with the development server to get an interactive Python debugger prompt at that line in your code—then you can interact with the request and response objects of your actual site on the command line. Just be VERY CAREFUL not to leave that line in when you deploy the site, as it will hang your web server. Installing http://pypi.python.org/pypi/ipdb gives you an IPython shell here with import ipdb; ipdb.set_trace().
I wrote a bunch of tips on debugging Django a few years ago: http://blog.simonwillison.net/po...
More recent articles
- My AI/LLM predictions for the next 1, 3 and 6 years, for Oxide and Friends - 10th January 2025
- Weeknotes: Starting 2025 a little slow - 4th January 2025
- I still don't think companies serve you ads based on spying through your microphone - 2nd January 2025