@@ -47,7 +47,29 @@ def __init__(self, *args, **kwargs):
47
47
template_rendered .connect (self ._store_template_info )
48
48
49
49
def _store_template_info (self , sender , ** kwargs ):
50
- kwargs ['context' ] = kwargs ['context' ].__copy__ ()
50
+ context_data = kwargs ['context' ]
51
+
52
+ context_list = []
53
+ for context_layer in context_data .dicts :
54
+ if hasattr (context_layer , 'items' ):
55
+ for key , value in context_layer .items ():
56
+ # Replace any request elements - they have a large
57
+ # unicode representation and the request data is
58
+ # already made available from the Request Vars panel.
59
+ if isinstance (value , http .HttpRequest ):
60
+ context_layer [key ] = '<<request>>'
61
+ # Replace the debugging sql_queries element. The SQL
62
+ # data is already made available from the SQL panel.
63
+ elif key == 'sql_queries' and isinstance (value , list ):
64
+ context_layer [key ] = '<<sql_queries>>'
65
+ # Replace LANGUAGES, which is available in i18n context processor
66
+ elif key == 'LANGUAGES' and isinstance (value , tuple ):
67
+ context_layer [key ] = '<<languages>>'
68
+ try :
69
+ context_list .append (pformat (context_layer ))
70
+ except UnicodeEncodeError :
71
+ pass
72
+ kwargs ['context' ] = context_list
51
73
self .templates .append (kwargs )
52
74
53
75
def nav_title (self ):
@@ -88,28 +110,7 @@ def content(self):
88
110
info ['template' ] = template
89
111
# Clean up context for better readability
90
112
if getattr (settings , 'DEBUG_TOOLBAR_CONFIG' , {}).get ('SHOW_TEMPLATE_CONTEXT' , True ):
91
- context_data = template_data .get ('context' , None )
92
-
93
- context_list = []
94
- for context_layer in context_data .dicts :
95
- if hasattr (context_layer , 'items' ):
96
- for key , value in context_layer .items ():
97
- # Replace any request elements - they have a large
98
- # unicode representation and the request data is
99
- # already made available from the Request Vars panel.
100
- if isinstance (value , http .HttpRequest ):
101
- context_layer [key ] = '<<request>>'
102
- # Replace the debugging sql_queries element. The SQL
103
- # data is already made available from the SQL panel.
104
- elif key == 'sql_queries' and isinstance (value , list ):
105
- context_layer [key ] = '<<sql_queries>>'
106
- # Replace LANGUAGES, which is available in i18n context processor
107
- elif key == 'LANGUAGES' and isinstance (value , tuple ):
108
- context_layer [key ] = '<<languages>>'
109
- try :
110
- context_list .append (pformat (context_layer ))
111
- except UnicodeEncodeError :
112
- pass
113
+ context_list = template_data .get ('context' , [])
113
114
info ['context' ] = '\n ' .join (context_list )
114
115
template_context .append (info )
115
116
0 commit comments