diff options
| author | Mikhail Korobov | 2010-01-08 11:11:58 -0800 |
|---|---|---|
| committer | Rob Hudson | 2010-01-08 11:13:37 -0800 |
| commit | 5701e1f21b4178da66dc017ac57ab91c06088bdf (patch) | |
| tree | 6c9116b6035e79634e84951f85e56fa43b52046f | |
| parent | 065162d7f55405aa897d65885b74f06861bd54ee (diff) | |
| download | django-debug-toolbar-5701e1f21b4178da66dc017ac57ab91c06088bdf.tar.bz2 | |
Print non-iterable template context layers as-is
Signed-off-by: Rob Hudson <rob@cogit8.org>
| -rw-r--r-- | debug_toolbar/panels/template.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py index f6226c4..86b1c3e 100644 --- a/debug_toolbar/panels/template.py +++ b/debug_toolbar/panels/template.py @@ -83,19 +83,20 @@ class TemplateDebugPanel(DebugPanel): context_list = [] for context_layer in context_data.dicts: - for key, value in context_layer.items(): - # Replace any request elements - they have a large - # unicode representation and the request data is - # already made available from the Request Vars panel. - if isinstance(value, http.HttpRequest): - context_layer[key] = '<<request>>' - # Replace the debugging sql_queries element. The SQL - # data is already made available from the SQL panel. - elif key == 'sql_queries' and isinstance(value, list): - context_layer[key] = '<<sql_queries>>' - # Replace LANGUAGES, which is available in i18n context processor - elif key == 'LANGUAGES' and isinstance(value, tuple): - context_layer[key] = '<<languages>>' + if hasattr(context_layer, 'items'): + for key, value in context_layer.items(): + # Replace any request elements - they have a large + # unicode representation and the request data is + # already made available from the Request Vars panel. + if isinstance(value, http.HttpRequest): + context_layer[key] = '<<request>>' + # Replace the debugging sql_queries element. The SQL + # data is already made available from the SQL panel. + elif key == 'sql_queries' and isinstance(value, list): + context_layer[key] = '<<sql_queries>>' + # Replace LANGUAGES, which is available in i18n context processor + elif key == 'LANGUAGES' and isinstance(value, tuple): + context_layer[key] = '<<languages>>' try: context_list.append(pformat(context_layer)) except UnicodeEncodeError: |
