How can I look up Django functions?
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
- ChatGPT should include inline tips - 30th May 2023
- Lawyer cites fake cases invented by ChatGPT, judge is not amused - 27th May 2023
- llm, ttok and strip-tags - CLI tools for working with ChatGPT and other LLMs - 18th May 2023
- Delimiters won't save you from prompt injection - 11th May 2023
- Weeknotes: sqlite-utils 3.31, download-esm, Python in a sandbox - 10th May 2023
- Leaked Google document: "We Have No Moat, And Neither Does OpenAI" - 4th May 2023
- Midjourney 5.1 - 4th May 2023
- Prompt injection explained, with video, slides, and a transcript - 2nd May 2023
- download-esm: a tool for downloading ECMAScript modules - 2nd May 2023
- Let's be bear or bunny - 1st May 2023