diff options
| author | Chris Beaven | 2009-09-29 11:54:37 +1300 |
|---|---|---|
| committer | Rob Hudson | 2009-09-30 07:07:52 -0700 |
| commit | 1ca31fe54936d29f15cf23d92b9ab331e5199707 (patch) | |
| tree | 7a277d77ac8b95ea97440d337a33704583373274 | |
| parent | 97c1240a8fbeb6ed374b94a0bc630bca8a7e1d6b (diff) | |
| download | django-debug-toolbar-1ca31fe54936d29f15cf23d92b9ab331e5199707.tar.bz2 | |
Template panel: Remove unnecessary large elements from each template context (request and sql_queries)
Signed-off-by: Rob Hudson <rob@cogit8.org>
| -rw-r--r-- | debug_toolbar/panels/template.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py index 34a1897..cc3b1e1 100644 --- a/debug_toolbar/panels/template.py +++ b/debug_toolbar/panels/template.py @@ -1,6 +1,7 @@ from os.path import normpath from pprint import pformat +from django import http from django.conf import settings from django.core.signals import request_started from django.dispatch import Signal @@ -80,13 +81,24 @@ class TemplateDebugPanel(DebugPanel): if getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('SHOW_TEMPLATE_CONTEXT', True): c = d.get('context', None) - d_list = [] - for _d in c.dicts: + context_list = [] + for context_layer in c.dicts: + for key, value in context_layer.items(): + # Replace any request elements - they have a large + # unicode representation. The request data is already + # made available from the Request Vars panel. + if isinstance(value, http.HttpRequest): + context_layer[key] = '<request>' + # Remove the debugging sql_queries element from the + # context. The SQL data is already made available from + # the SQL panel. + elif key == 'sql_queries' and isinstance(value, list): + del context_layer[key] try: - d_list.append(pformat(_d)) + context_list.append(pformat(context_layer)) except UnicodeEncodeError: pass - info['context'] = '\n'.join(d_list) + info['context'] = '\n'.join(context_list) template_context.append(info) context = { 'templates': template_context, |
