diff options
| -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: |
