trbs / django-debug-toolbar

A configurable set of panels that display various debug information about the current request/response.
http://rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

==================== Django Debug Toolbar

The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content.

Currently, the following panels have been written and are working:

If you have ideas for other panels please let us know.

Installation

. Add the debug_toolbar directory to your Python path.

. Add the following middleware to your project's settings.py file:

``'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).

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.

. 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',)

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.

Alternatively, add the path to the debug toolbar templates ('path/to/debug_toolbar/templates' to your TEMPLATE_DIRS setting.)

Configuration

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

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.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 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:

TODOs and BUGS

See: http://code.google.com/p/django-debug-toolbar/issues/list