diff options
| author | Aymeric Augustin | 2013-10-27 12:29:57 -0700 |
|---|---|---|
| committer | Aymeric Augustin | 2013-10-27 12:29:57 -0700 |
| commit | dcfa0eaa25c948f4b9e544e1bee489403014d3e7 (patch) | |
| tree | f132e5a5d0cbd6d3c18de46b62567c4584cd870a /docs/commands.rst | |
| parent | 7d5593bc528cd1f350b23093b00807f15e6153a3 (diff) | |
| parent | 00a2b9734f382ef8395cc85e1406c9800dcc5d0f (diff) | |
| download | django-debug-toolbar-dcfa0eaa25c948f4b9e544e1bee489403014d3e7.tar.bz2 | |
Merge pull request #430 from aaugustin/sphinx-docs
Convert README to Sphinx docs.
Diffstat (limited to 'docs/commands.rst')
| -rw-r--r-- | docs/commands.rst | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/commands.rst b/docs/commands.rst new file mode 100644 index 0000000..1d81a05 --- /dev/null +++ b/docs/commands.rst @@ -0,0 +1,47 @@ +Commands +======== + +The Debug Toolbar currently provides one Django management command. + +``debugsqlshell`` +----------------- + +This command starts an interactive Python shell, like Django's built-in +``shell`` management command. In addition, each ORM call that results in a +database query will be beautifully output in the shell. + +Here's an example:: + + >>> from page.models import Page + >>> ### Lookup and use resulting in an extra query... + >>> p = Page.objects.get(pk=1) + SELECT "page_page"."id", + "page_page"."number", + "page_page"."template_id", + "page_page"."description" + FROM "page_page" + WHERE "page_page"."id" = 1 + + >>> print p.template.name + SELECT "page_template"."id", + "page_template"."name", + "page_template"."description" + FROM "page_template" + WHERE "page_template"."id" = 1 + + Home + >>> ### Using select_related to avoid 2nd database call... + >>> p = Page.objects.select_related('template').get(pk=1) + SELECT "page_page"."id", + "page_page"."number", + "page_page"."template_id", + "page_page"."description", + "page_template"."id", + "page_template"."name", + "page_template"."description" + FROM "page_page" + INNER JOIN "page_template" ON ("page_page"."template_id" = "page_template"."id") + WHERE "page_page"."id" = 1 + + >>> print p.template.name + Home |
