diff options
| author | Aymeric Augustin | 2013-11-13 20:40:22 +0100 |
|---|---|---|
| committer | Aymeric Augustin | 2013-11-13 20:40:22 +0100 |
| commit | 97090c32941784d28818721f37eee69e21e2d74e (patch) | |
| tree | fdabb0301faf9595312b908e738638d18ecffacb /debug_toolbar | |
| parent | a3acf6b57275f2a14cde7c209a8b6dff107275b0 (diff) | |
| download | django-debug-toolbar-97090c32941784d28818721f37eee69e21e2d74e.tar.bz2 | |
Provide an option to force rendering panels in page.
Requested by David who seems to runs the debug toolbar in production :-)
Diffstat (limited to 'debug_toolbar')
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/base.html | 1 | ||||
| -rw-r--r-- | debug_toolbar/toolbar.py | 13 | ||||
| -rw-r--r-- | debug_toolbar/utils/settings.py | 1 |
3 files changed, 11 insertions, 4 deletions
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html index c3cd339..b2ea63e 100644 --- a/debug_toolbar/templates/debug_toolbar/base.html +++ b/debug_toolbar/templates/debug_toolbar/base.html @@ -53,6 +53,7 @@ if(!window.jQuery) document.write('<scr'+'ipt src="{{ STATIC_URL }}debug_toolbar </div> <div class="djDebugPanelContent"> <div class="scroll"> + {% if not storage_id %}{{ panel.content }}{% endif %} </div> </div> </div> diff --git a/debug_toolbar/toolbar.py b/debug_toolbar/toolbar.py index bf632cd..3f274d0 100644 --- a/debug_toolbar/toolbar.py +++ b/debug_toolbar/toolbar.py @@ -51,10 +51,9 @@ class DebugToolbar(object): Renders the overall Toolbar with panels inside. """ context = self.template_context.copy() - context.update({ - 'panels': self.panels, - 'storage_id': self.store(), - }) + context['panels'] = self.panels + if not self.should_render_panels(): + context['storage_id'] = self.store() return render_to_string('debug_toolbar/base.html', context) # Handle storing toolbars in memory and fetching them later on @@ -62,6 +61,12 @@ class DebugToolbar(object): _counter = 0 _storage = SortedDict() + def should_render_panels(self): + render_panels = dt_settings.CONFIG['RENDER_PANELS'] + if render_panels is None: + render_panels = self.request.META['wsgi.multiprocess'] + return render_panels + def store(self): cls = type(self) cls._counter += 1 diff --git a/debug_toolbar/utils/settings.py b/debug_toolbar/utils/settings.py index 45f661f..323e7cf 100644 --- a/debug_toolbar/utils/settings.py +++ b/debug_toolbar/utils/settings.py @@ -28,6 +28,7 @@ CONFIG_DEFAULTS = { 'ROOT_TAG_ATTRS': '', 'SQL_WARNING_THRESHOLD': 500, # milliseconds 'RESULTS_CACHE_SIZE': 10, + 'RENDER_PANELS': None, } |
