diff options
| author | Aymeric Augustin | 2013-10-27 14:41:22 +0100 | 
|---|---|---|
| committer | Aymeric Augustin | 2013-10-27 14:41:22 +0100 | 
| commit | 6e4b8d95b8bcdeeab039f0a0c7e6d6833cd8685e (patch) | |
| tree | d110f54face6d32b459c4a43fce0ed5c66bcc839 /docs/commands.rst | |
| parent | 0b05a1b7257079d623012cd06cade1be4a0ff0d4 (diff) | |
| download | django-debug-toolbar-6e4b8d95b8bcdeeab039f0a0c7e6d6833cd8685e.tar.bz2 | |
Migrate info from README to docs.
Diffstat (limited to 'docs/commands.rst')
| -rw-r--r-- | docs/commands.rst | 45 | 
1 files changed, 45 insertions, 0 deletions
| diff --git a/docs/commands.rst b/docs/commands.rst index 675c188..1d81a05 100644 --- a/docs/commands.rst +++ b/docs/commands.rst @@ -1,2 +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 | 
