aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Leidel2012-08-27 12:46:54 +0200
committerJannis Leidel2012-08-27 12:54:26 +0200
commit73af56da5ff2d1bba47387cc650ea16c88fbffc0 (patch)
treea199c5af07becca44759b70b594b72a998d4ec50
parent4c3474b140e8e1289f6468349f225a42386c9ee0 (diff)
downloaddjango-debug-toolbar-73af56da5ff2d1bba47387cc650ea16c88fbffc0.tar.bz2
Cosmetic fixes to the README file.
-rw-r--r--README.rst160
1 files changed, 87 insertions, 73 deletions
diff --git a/README.rst b/README.rst
index 1f51ce9..bf32739 100644
--- a/README.rst
+++ b/README.rst
@@ -20,8 +20,8 @@ Currently, the following panels have been written and are working:
There is also one Django management command currently:
-- `debugsqlshell`: Outputs the SQL that gets executed as you work in the Python
- interactive shell. (See example below)
+- ``debugsqlshell``: Outputs the SQL that gets executed as you work in the
+ Python interactive shell. (See example below)
If you have ideas for other panels please let us know.
@@ -30,129 +30,143 @@ If you have ideas for other panels please let us know.
Installation
============
-#. Add the `debug_toolbar` directory to your Python path.
+#. Add the ``debug_toolbar`` directory to your Python path.
-#. Add the following middleware to your project's `settings.py` file::
+#. Add the following middleware to your project's ``settings.py`` file::
- 'debug_toolbar.middleware.DebugToolbarMiddleware',
+ MIDDLEWARE_CLASSES = (
+ # ...
+ 'debug_toolbar.middleware.DebugToolbarMiddleware',
+ # ...
+ )
Tying into middleware allows each panel to be instantiated on request and
rendering to happen on response.
- The order of MIDDLEWARE_CLASSES is important: the Debug Toolbar middleware
- must come after any other middleware that encodes the response's content
- (such as GZipMiddleware).
+ The order of ``MIDDLEWARE_CLASSES`` is important: the Debug Toolbar
+ middleware must come after any other middleware that encodes the
+ response's content (such as GZipMiddleware).
- Note: The debug toolbar will only display itself if the mimetype of the
- response is either `text/html` or `application/xhtml+xml` and contains a
- closing `</body>` tag.
+ **Note**: The debug toolbar will only display itself if the mimetype of the
+ response is either ``text/html`` or ``application/xhtml+xml`` and contains a
+ closing ``</body>`` tag.
- Note: Be aware of middleware ordering and other middleware that may
- intercept requests and return responses. Putting the debug toolbar
+ **Note**: Be aware of middleware ordering and other middleware that may
+ intercept requests and return responses. Putting the debug toolbar
middleware *after* the Flatpage middleware, for example, means the
toolbar will not show up on flatpages.
-#. Make sure your IP is listed in the `INTERNAL_IPS` setting. If you are
+#. Make sure your IP is listed in the ``INTERNAL_IPS`` setting. If you are
working locally this will be::
- INTERNAL_IPS = ('127.0.0.1',)
+ INTERNAL_IPS = ('127.0.0.1',)
- Note: This is required because of the built-in requirements of the
- `show_toolbar` method. See below for how to define a method to determine
+ **Note**: This is required because of the built-in requirements of the
+ ``show_toolbar`` method. See below for how to define a method to determine
your own logic for displaying the toolbar.
-#. Add `debug_toolbar` to your `INSTALLED_APPS` setting so Django can find the
- template files associated with the Debug Toolbar::
+#. Add ``debug_toolbar`` to your ``INSTALLED_APPS`` setting so Django can
+ find the template files associated with the Debug Toolbar::
- INSTALLED_APPS = (
- ...
- 'debug_toolbar',
- )
- Alternatively, add the path to the debug toolbar templates
- (``'path/to/debug_toolbar/templates'`` to your ``TEMPLATE_DIRS`` setting.)
+ INSTALLED_APPS = (
+ ...
+ 'debug_toolbar',
+ )
Configuration
=============
-The debug toolbar has two settings that can be set in `settings.py`:
+The debug toolbar has two settings that can be set in ``settings.py``:
-#. Optional: Add a tuple called `DEBUG_TOOLBAR_PANELS` to your ``settings.py``
+#. Optional: Add a tuple called ``DEBUG_TOOLBAR_PANELS`` to your ``settings.py``
file that specifies the full Python path to the panel that you want included
- in the Toolbar. This setting looks very much like the `MIDDLEWARE_CLASSES`
- setting. For example::
-
- DEBUG_TOOLBAR_PANELS = (
- 'debug_toolbar.panels.version.VersionDebugPanel',
- 'debug_toolbar.panels.timer.TimerDebugPanel',
- 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
- 'debug_toolbar.panels.headers.HeaderDebugPanel',
- 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
- 'debug_toolbar.panels.template.TemplateDebugPanel',
- 'debug_toolbar.panels.sql.SQLDebugPanel',
- 'debug_toolbar.panels.signals.SignalDebugPanel',
- 'debug_toolbar.panels.logger.LoggingPanel',
- )
+ in the Toolbar. This setting looks very much like the ``MIDDLEWARE_CLASSES``
+ setting. For example::
+
+ DEBUG_TOOLBAR_PANELS = (
+ 'debug_toolbar.panels.version.VersionDebugPanel',
+ 'debug_toolbar.panels.timer.TimerDebugPanel',
+ 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
+ 'debug_toolbar.panels.headers.HeaderDebugPanel',
+ 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
+ 'debug_toolbar.panels.template.TemplateDebugPanel',
+ 'debug_toolbar.panels.sql.SQLDebugPanel',
+ 'debug_toolbar.panels.signals.SignalDebugPanel',
+ 'debug_toolbar.panels.logger.LoggingPanel',
+ )
You can change the ordering of this tuple to customize the order of the
- panels you want to display, or add/remove panels. If you have custom panels
+ panels you want to display, or add/remove panels. If you have custom panels
you can include them in this way -- just provide the full Python path to
your panel.
#. Optional: There are a few configuration options to the debug toolbar that
- can be placed in a dictionary:
+ can be placed in a dictionary called ``DEBUG_TOOLBAR_CONFIG``:
- * `INTERCEPT_REDIRECTS`: If set to True (default), the debug toolbar will
+ * ``INTERCEPT_REDIRECTS``
+
+ If set to True (default), the debug toolbar will
show an intermediate page upon redirect so you can view any debug
- information prior to redirecting. This page will provide a link to the
- redirect destination you can follow when ready. If set to False, redirects
+ information prior to redirecting. This page will provide a link to the
+ redirect destination you can follow when ready. If set to False, redirects
will proceed as normal.
- * `SHOW_TOOLBAR_CALLBACK`: If not set or set to None, the debug_toolbar
+ * ``SHOW_TOOLBAR_CALLBACK``
+
+ If not set or set to None, the debug_toolbar
middleware will use its built-in show_toolbar method for determining whether
- the toolbar should show or not. The default checks are that DEBUG must be
- set to True or the IP of the request must be in INTERNAL_IPS. You can
+ the toolbar should show or not. The default checks are that DEBUG must be
+ set to True or the IP of the request must be in INTERNAL_IPS. You can
provide your own method for displaying the toolbar which contains your
- custom logic. This method should return True or False.
+ custom logic. This method should return True or False.
+
+ * ``EXTRA_SIGNALS``
- * `EXTRA_SIGNALS`: An array of custom signals that might be in your project,
+ An array of custom signals that might be in your project,
defined as the python path to the signal.
- * `HIDE_DJANGO_SQL`: If set to True (the default) then code in Django itself
+ * ``HIDE_DJANGO_SQL``
+
+ If set to True (the default) then code in Django itself
won't be shown in SQL stacktraces.
- * `SHOW_TEMPLATE_CONTEXT`: If set to True (the default) then a template's
- context will be included with it in the Template debug panel. Turning this
+ * ``SHOW_TEMPLATE_CONTEXT``
+
+ If set to True (the default) then a template's
+ context will be included with it in the Template debug panel. Turning this
off is useful when you have large template contexts, or you have template
contexts with lazy datastructures that you don't want to be evaluated.
- * `TAG`: If set, this will be the tag to which debug_toolbar will attach the
+ * ``TAG``
+
+ If set, this will be the tag to which debug_toolbar will attach the
debug toolbar. Defaults to 'body'.
- * `ENABLE_STACKTRACES`: If set, this will show stacktraces for SQL queries
+ * ``ENABLE_STACKTRACES``
+
+ If set, this will show stacktraces for SQL queries
and cache calls. Enabling stacktraces can increase the CPU time used when
executing queries. Defaults to True.
Example configuration::
- def custom_show_toolbar(request):
- return True # Always show toolbar, for example purposes only.
-
- DEBUG_TOOLBAR_CONFIG = {
- 'INTERCEPT_REDIRECTS': False,
- 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
- 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
- 'HIDE_DJANGO_SQL': False,
- 'TAG': 'div',
- 'ENABLE_STACKTRACES' : True,
- }
-
-#. note: HTML page (your templates) must contain closed body tag, meta tag with content="text/html.
- toolbar wont display itself in other pages
+ def custom_show_toolbar(request):
+ return True # Always show toolbar, for example purposes only.
+
+ DEBUG_TOOLBAR_CONFIG = {
+ 'INTERCEPT_REDIRECTS': False,
+ 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
+ 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
+ 'HIDE_DJANGO_SQL': False,
+ 'TAG': 'div',
+ 'ENABLE_STACKTRACES' : True,
+ }
+
+``debugsqlshell``
+=================
-`debugsqlshell`
-===============
The following is sample output from running the `debugsqlshell` management
-command. Each ORM call that results in a database query will be beautifully
+command. Each ORM call that results in a database query will be beautifully
output in the shell::
$ ./manage.py debugsqlshell