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
- Weeknotes: Getting ready for NICAR - 27th February 2024
- The killer app of Gemini Pro 1.5 is video - 21st February 2024
- Weeknotes: a Datasette release, an LLM release and a bunch of new plugins - 9th February 2024
- LLM 0.13: The annotated release notes - 26th January 2024
- Weeknotes: datasette-test, datasette-build, PSF board retreat - 21st January 2024
- Talking about Open Source LLMs on Oxide and Friends - 17th January 2024
- Publish Python packages to PyPI with a python-lib cookiecutter template and GitHub Actions - 16th January 2024
- What I should have said about the term Artificial Intelligence - 9th January 2024
- Weeknotes: Page caching and custom templates for Datasette Cloud - 7th January 2024