Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Moving default list of panels into the loader to skip an install step…

…. Panel

list can still be overridden with a setting if desired.  Updated README as
well.
  • Loading branch information...
commit ec38c74d20606182d9b9462977e185f0c37e99b2 1 parent 4056bf7
orcasrob orcasrob authored

Showing 2 changed files with 25 additions and 10 deletions. Show diff stats Hide diff stats

  1. +9 8 README.rst
  2. +16 2 debug_toolbar/toolbar/loader.py
17 README.rst
Source Rendered
@@ -41,10 +41,13 @@ Installation
41 41
42 42 INTERNAL_IPS = ('127.0.0.1',)
43 43
44   -#. Add a tuple called `DEBUG_TOOLBAR_PANELS` to your ``settings.py`` file that
45   - specifies the full Python path to the panel that you want included in the
46   - Toolbar. This setting looks very much like the `MIDDLEWARE_CLASSES` setting.
47   - For example::
  44 +#. Add `debug_toolbar` to your `INSTALLED_APPS` setting so Django can find the
  45 + the template files associated with the Debug Toolbar.
  46 +
  47 +#. Optional: Add a tuple called `DEBUG_TOOLBAR_PANELS` to your ``settings.py``
  48 + file that specifies the full Python path to the panel that you want included
  49 + in the Toolbar. This setting looks very much like the `MIDDLEWARE_CLASSES`
  50 + setting. For example::
48 51
49 52 DEBUG_TOOLBAR_PANELS = (
50 53 'debug_toolbar.panels.version.VersionDebugPanel',
@@ -57,10 +60,8 @@ Installation
57 60 )
58 61
59 62 You can change the ordering of this tuple to customize the order of the
60   - panels you want to display.
61   -
62   -#. Add `debug_toolbar` to your `INSTALLED_APPS` setting so Django can find the
63   - the template files associated with the Debug Toolbar.
  63 + panels you want to display. And you can include panels that you have created
  64 + or that are specific to your project.
64 65
65 66 TODO
66 67 ====
18 debug_toolbar/toolbar/loader.py
@@ -10,15 +10,29 @@ def __init__(self, request):
10 10 self.panels = []
11 11 self.panel_list = []
12 12 self.content_list = []
  13 + # Override this tuple by copying to settings.py as `DEBUG_TOOLBAR_PANELS`
  14 + self.default_panels = (
  15 + 'debug_toolbar.panels.version.VersionDebugPanel',
  16 + 'debug_toolbar.panels.timer.TimerDebugPanel',
  17 + 'debug_toolbar.panels.headers.HeaderDebugPanel',
  18 + 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
  19 + 'debug_toolbar.panels.sql.SQLDebugPanel',
  20 + 'debug_toolbar.panels.cache.CacheDebugPanel',
  21 + 'debug_toolbar.panels.template.TemplateDebugPanel',
  22 + )
13 23
14 24 def load_panels(self):
15 25 """
16   - Populate debug panel lists from settings.DEBUG_TOOLBAR_PANELS.
  26 + Populate debug panels
17 27 """
18 28 from django.conf import settings
19 29 from django.core import exceptions
20 30
21   - for panel_path in settings.DEBUG_TOOLBAR_PANELS:
  31 + # Check if settings has a DEBUG_TOOLBAR_PANELS, otherwise use default
  32 + if hasattr(settings, 'DEBUG_TOOLBAR_PANELS'):
  33 + self.default_panels = settings.DEBUG_TOOLBAR_PANELS
  34 +
  35 + for panel_path in self.default_panels:
22 36 try:
23 37 dot = panel_path.rindex('.')
24 38 except ValueError:

0 comments on commit ec38c74

Please sign in to comment.
Something went wrong with that request. Please try again.