diff options
24 files changed, 548 insertions, 445 deletions
| diff --git a/debug_toolbar/media/debug_toolbar/back.png b/debug_toolbar/media/debug_toolbar/back.pngBinary files differ index fa6a36b..6ac8a52 100644 --- a/debug_toolbar/media/debug_toolbar/back.png +++ b/debug_toolbar/media/debug_toolbar/back.png diff --git a/debug_toolbar/media/debug_toolbar/back_hover.png b/debug_toolbar/media/debug_toolbar/back_hover.pngBinary files differ index 774f97c..452b673 100644 --- a/debug_toolbar/media/debug_toolbar/back_hover.png +++ b/debug_toolbar/media/debug_toolbar/back_hover.png diff --git a/debug_toolbar/media/debug_toolbar/close.png b/debug_toolbar/media/debug_toolbar/close.pngBinary files differ index c22e2e8..c0e8135 100644 --- a/debug_toolbar/media/debug_toolbar/close.png +++ b/debug_toolbar/media/debug_toolbar/close.png diff --git a/debug_toolbar/media/debug_toolbar/close_hover.png b/debug_toolbar/media/debug_toolbar/close_hover.pngBinary files differ index f868e80..5b2c812 100644 --- a/debug_toolbar/media/debug_toolbar/close_hover.png +++ b/debug_toolbar/media/debug_toolbar/close_hover.png diff --git a/debug_toolbar/media/debug_toolbar/djdt_vertical.png b/debug_toolbar/media/debug_toolbar/djdt_vertical.pngBinary files differ new file mode 100644 index 0000000..000c60f --- /dev/null +++ b/debug_toolbar/media/debug_toolbar/djdt_vertical.png diff --git a/debug_toolbar/media/debug_toolbar/indicator.png b/debug_toolbar/media/debug_toolbar/indicator.pngBinary files differ index a21fc6e..1a2c578 100644 --- a/debug_toolbar/media/debug_toolbar/indicator.png +++ b/debug_toolbar/media/debug_toolbar/indicator.png diff --git a/debug_toolbar/media/debug_toolbar/toolbar.css b/debug_toolbar/media/debug_toolbar/toolbar.css index 9da3f32..316f4df 100644 --- a/debug_toolbar/media/debug_toolbar/toolbar.css +++ b/debug_toolbar/media/debug_toolbar/toolbar.css @@ -1,53 +1,48 @@ -/* Debug Toolbar CSS Reset, adapted from YUI CSS Reset */ +/* Debug Toolbar CSS Reset, adapted from Eric Meyer's CSS Reset */  #djDebug {color:#000;background:#FFF;} -#djDebug div,#djDebug dl,#djDebug dt,#djDebug dd,#djDebug ul,#djDebug ol,#djDebug li,#djDebug h1,#djDebug h2,#djDebug h3,#djDebug h4,#djDebug h5,#djDebug h6,#djDebug pre,#djDebug code,#djDebug form,#djDebug fieldset,#djDebug legend,#djDebug input,#djDebug button,#djDebug textarea,#djDebug p,#djDebug blockquote,#djDebug th,#djDebug td{margin:0;padding:0;} -#djDebug table{border-collapse:collapse;border-spacing:0;} -#djDebug fieldset,#djDebug img{border:0;} -#djDebug address,#djDebug caption,#djDebug cite,#djDebug code,#djDebug dfn,#djDebug em,#djDebug strong,#djDebug th,#djDebug var,#djDebug optgroup{font-style:inherit;font-weight:inherit;} -#djDebug del,#djDebug ins{text-decoration:none;} -#djDebug li{list-style:none;} -#djDebug caption,#djDebug th{text-align:left;} -#djDebug h1,#djDebug h2,#djDebug h3,#djDebug h4,#djDebug h5,#djDebug h6{font-size:100%;font-weight:normal;} -#djDebug q:before,#djDebug q:after{content:'';} -#djDebug abbr,#djDebug acronym{border:0;font-variant:normal;} -#djDebug sup{vertical-align:baseline;} -#djDebug sub{vertical-align:baseline;} -#djDebug legend{color:#000;} -#djDebug input,#djDebug button,#djDebug textarea,#djDebug select,#djDebug optgroup,#djDebug option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;} -#djDebug input,#djDebug button,#djDebug textarea,#djDebug select{*font-size:100%;} - -#djDebug * { -	color:#000; -	float:none; -	margin:0; -	padding:0; -	position:static; -	text-align:left; -	font-family:sans-serif; -} - -#djDebugToolbar { +#djDebug, #djDebug div, #djDebug span, #djDebug applet, #djDebug object, #djDebug iframe, +#djDebug h1, #djDebug h2, #djDebug h3, #djDebug h4, #djDebug h5, #djDebug h6, #djDebug p, blockquote, #djDebug pre, +#djDebug a, #djDebug abbr, #djDebug acronym, #djDebug address, #djDebug big, #djDebug cite, #djDebug code, +#djDebug del, #djDebug dfn, #djDebug em, #djDebug font, #djDebug img, #djDebug ins, #djDebug kbd, #djDebug q, #djDebug s, #djDebug samp, +#djDebug small, #djDebug strike, #djDebug strong, #djDebug sub, #djDebug sup, #djDebug tt, #djDebug var, +#djDebug b, #djDebug u, #djDebug i, #djDebug center, +#djDebug dl, #djDebug dt, #djDebug dd, #djDebug ol, #djDebug ul, #djDebug li, +#djDebug fieldset, #djDebug form, #djDebug label, #djDebug legend, +#djDebug table, #djDebug caption, #djDebug tbody, #djDebug tfoot, #djDebug thead, #djDebug tr, #djDebug th, #djDebug td { +	margin: 0; +	padding: 0; +	border: 0; +	outline: 0; +	font-size: 12px; +	line-height: 1.5em; +	color: #000; +	vertical-align: baseline; +	background: transparent; +	font-family: sans-serif; +} + +#djDebug #djDebugToolbar {  	background:#111;  	width:200px;  	z-index:100000000; -	position:absolute; +	position:fixed;  	top:0;  	bottom:0;  	right:0;  	opacity:0.9;  } -#djDebugToolbar small { +#djDebug #djDebugToolbar small {  	color:#999;  } -#djDebugToolbar ul { +#djDebug #djDebugToolbar ul {  	margin:0;  	padding:0;  	list-style:none;  } -#djDebugToolbar li { +#djDebug #djDebugToolbar li {  	border-bottom:1px solid #222;  	color:#fff;  	display:block; @@ -59,11 +54,10 @@  	width:auto;  } -#djDebugToolbar li>a, -#djDebugToolbar li>div.contentless  { +#djDebug #djDebugToolbar li>a, +#djDebug #djDebugToolbar li>div.contentless  {  	font-weight:normal;  	font-style:normal; -	font-variant:small-caps;  	text-decoration:none;  	display:block;  	font-size:16px; @@ -71,57 +65,67 @@  	color:#fff;  } -#djDebugToolbar li a:hover { +#djDebug #djDebugToolbar li a:hover {  	color:#111; -	background-color:#c6d6da; -	border-right:10px solid #fff; +	background-color:#ffc;  } -#djDebugToolbar li.active { +#djDebug #djDebugToolbar li.active {  	background-image:url(indicator.png);  	background-repeat:no-repeat;  	background-position:left center; +	background-color:#333; +	padding-left:10px;	  } -#djDebugToolbar li.active a:hover { -	background-color:#111; -	background-image:inherit; -	background-position:inherit; -	background-repeat:inherit; +#djDebug #djDebugToolbar li.active a:hover {  	color:#b36a60; -	border:none; +	background-color:transparent;  } -#djDebugToolbar li small { +#djDebug #djDebugToolbar li small {  	font-size:12px;  	color:#999; -	font-style:italic; +	font-style:normal;  	text-decoration:none; -	font-variant:normal; +	font-variant:small-caps;  } -#djDebugToolbarHandle { -	position:absolute; -	background:#111; -	top:0; -	bottom:0; +#djDebug #djDebugToolbarHandle { +	position:fixed; +	background:#fff; +	border:1px solid #111; +	top:30px;  	right:0;  	z-index:100000000; +	opacity:0.75;  }  #djDebug a#djShowToolBarButton {  	display:block; -	height:100%; -	padding:2px; +	height:75px; +	width:30px; +	border-right:none; +	border-bottom:4px solid #fff; +	border-top:4px solid #fff; +	border-left:4px solid #fff;  	color:#fff;  	font-size:10px;  	font-weight:bold;  	text-decoration:none;  	text-align:center; +	text-indent:-999999px; +	background:#000 url(djdt_vertical.png) no-repeat left center; +	opacity:0.5;  }  #djDebug a#djShowToolBarButton:hover { -	background-color:#f00; +	background-color:#111; +	padding-right:6px; +	border-top-color:#FFE761; +	border-left-color:#FFE761; +	border-bottom-color:#FFE761; +	opacity:1.0;  }  #djDebug pre { @@ -134,41 +138,59 @@  #djDebug .panelContent {  	display:none; -	position:absolute; +	position:fixed;  	margin:0;  	top:0;  	right:200px;  	bottom:0; -	left:0; -	background-color:#f6f6f6; +	left:0px; +	background-color:#eee;  	color:#666; -	z-index:1000000; -	overflow:auto; +	z-index:100000000;  }  #djDebug .panelContent > div {  	border-bottom:1px solid #ddd; -	padding:10px 20px;  } -.djDebugPanelTitle { +#djDebug .djDebugPanelTitle { +	position:absolute;  	background-color:#ffc;  	color:#666; +	padding-left:20px; +	top:0; +	right:0; +	left:0; +	height:50px; +} + +#djDebug .djDebugPanelContent { +	position:absolute; +	top:50px; +	right:0; +	bottom:0; +	left:0; +	height:auto; +	padding:0 0 0 20px; +} + +#djDebug .djDebugPanelContent .scroll { +	height:100%; +	overflow:auto; +	display:block; +	padding:0 10px 0 0;  } +  #djDebug h3 {  	font-size:24px; -	font-weight:bold; -	font-variant:small-caps; +	font-weight:normal; +	line-height:50px;  }  #djDebug h4 {  	font-size:20px;  	font-weight:bold; -} - -#djDebug .panelContent { -	background-color:#eee; -	color:#000; +	margin-top:0.8em;  }  #djDebug .panelContent table { @@ -176,6 +198,8 @@  	border-collapse:collapse;  	width:100%;  	background-color:#fff; +	display:block; +	margin-top:0.8em;  }  #djDebug .panelContent tbody td,  #djDebug .panelContent tbody th { @@ -199,7 +223,6 @@  #djDebug .panelContent code {  	font-family:Consolas, Monaco, "Bitstream Vera Sans Mono", "Lucida Console", monospace; -	font-size:12px;  }  /*  #djDebug .panelContent p a:hover, #djDebug .panelContent dd a:hover { @@ -257,8 +280,8 @@  	text-indent:-9999999px;  	display:block;  	position:absolute; -	top:0; -	right:10px; +	top:4px; +	right:15px;  	height:40px;  	width:40px;  	background:url(close.png) no-repeat center center; @@ -288,22 +311,68 @@  	margin-left:10px;  } +#djDebug a.toggleTemplate { +	padding:4px; +	background-color:#bbb; +	-moz-border-radius:3px; +	-webkit-border-radius:3px; +} + +#djDebug a.toggleTemplate:hover { +	padding:4px; +	background-color:#444; +	color:#ffe761; +	-moz-border-radius:3px; +	-webkit-border-radius:3px; +} + + +#djDebug a.djTemplateShowContext, #djDebug a.djTemplateShowContext span.toggleArrow { +	color:#999; +} + +#djDebug a.djTemplateShowContext:hover,  #djDebug a.djTemplateShowContext:hover span.toggleArrow { +	color:#000; +	cursor:pointer; +} + +#djDebug .djDebugSqlWrap { +	position:relative; +} + +#djDebug .djDebugSql { +	z-index:100000002; +} + +#djDebug span.djDebugLineChart { +	border-top:3px solid #777; +	position:absolute; +	bottom:0; +	top:0; +	left:0; +	display:block; +	z-index:1000000001; +} +#djDebug span.djDebugLineChartWarning { +	border-top-color:#900; +} +  #djDebug .highlight  { color:#000; }  #djDebug .highlight .err { color:#000; } /* Error */  #djDebug .highlight .g { color:#000; } /* Generic */ -#djDebug .highlight .k { color:#000; font-weight: bold } /* Keyword */ +#djDebug .highlight .k { color:#000; font-weight:bold } /* Keyword */  #djDebug .highlight .o { color:#000; } /* Operator */  #djDebug .highlight .n { color:#000; } /* Name */ -#djDebug .highlight .mi { color:#000; font-weight: bold } /* Literal.Number.Integer */ +#djDebug .highlight .mi { color:#000; font-weight:bold } /* Literal.Number.Integer */  #djDebug .highlight .l { color:#000; } /* Literal */  #djDebug .highlight .x { color:#000; } /* Other */  #djDebug .highlight .p { color:#000; } /* Punctuation */ -#djDebug .highlight .m { color:#000; font-weight: bold } /* Literal.Number */ +#djDebug .highlight .m { color:#000; font-weight:bold } /* Literal.Number */  #djDebug .highlight .s { color:#333 } /* Literal.String */  #djDebug .highlight .w { color:#888888 } /* Text.Whitespace */ -#djDebug .highlight .il { color:#000; font-weight: bold } /* Literal.Number.Integer.Long */ +#djDebug .highlight .il { color:#000; font-weight:bold } /* Literal.Number.Integer.Long */  #djDebug .highlight .na { color:#333 } /* Name.Attribute */ -#djDebug .highlight .nt { color:#000; font-weight: bold } /* Name.Tag */ +#djDebug .highlight .nt { color:#000; font-weight:bold } /* Name.Tag */  #djDebug .highlight .nv { color:#333 } /* Name.Variable */  #djDebug .highlight .s2 { color:#333 } /* Literal.String.Double */  #djDebug .highlight .cp { color:#333 } /* Comment.Preproc */ diff --git a/debug_toolbar/media/debug_toolbar/toolbar.js b/debug_toolbar/media/debug_toolbar/toolbar.js index b20a487..8155e2f 100644 --- a/debug_toolbar/media/debug_toolbar/toolbar.js +++ b/debug_toolbar/media/debug_toolbar/toolbar.js @@ -13,14 +13,14 @@ jQuery(function($j) {  				}  				current = $j('#djDebug #' + this.className);  				if (current.is(':visible')) { -					$j(document).trigger('close.djDebug'); -					$j(this).parent().removeClass("active"); +				    $j(document).trigger('close.djDebug'); +					$j(this).parent().removeClass('active');  				} else { -					$j('.panelContent').hide(); +					$j('.panelContent').hide(); // Hide any that are already open  					current.show();  					$j.djDebug.open(); -					$j('#djDebugToolbar li').removeClass("active"); -					$j(this).parent().addClass("active"); +					$j('#djDebugToolbar li').removeClass('active'); +					$j(this).parent().addClass('active');  				}  				return false;  			}); @@ -39,6 +39,7 @@ jQuery(function($j) {  				return false;  			});  			$j('#djDebugTemplatePanel a.djTemplateShowContext').click(function() { +				$j.djDebug.toggle_arrow($j(this).children('.toggleArrow'))  				$j.djDebug.toggle_content($j(this).parent().next());  				return false;  			}); @@ -57,15 +58,11 @@ jQuery(function($j) {  			if ($j.cookie(COOKIE_NAME)) {  				$j.djDebug.hide_toolbar(false);  			} else { -				$j('#djDebugToolbar').show(); +				$j.djDebug.show_toolbar(false);  			}  		},  		open: function() { -			$j(document).bind('keydown.djDebug', function(e) { -				if (e.keyCode == 27) { -					$j.djDebug.close(); -				} -			}); +			// TODO: Decide if we should remove this  		},  		toggle_content: function(elem) {  			if (elem.is(':visible')) { @@ -79,10 +76,16 @@ jQuery(function($j) {  			return false;  		},  		hide_toolbar: function(setCookie) { -			$j('#djDebugToolbar').hide("fast"); -			$j('#djDebugToolbar li').removeClass("active"); -			$j(document).trigger('close.djDebug'); +			// close any sub panels +			$j('#djDebugWindow').hide(); +			// close all panels +			$j('.panelContent').hide(); +			$j('#djDebugToolbar li').removeClass('active'); +			// finally close toolbar +			$j('#djDebugToolbar').hide('fast');  			$j('#djDebugToolbarHandle').show(); +			// Unbind keydown +			$j(document).unbind('keydown.djDebug');  			if (setCookie) {  				$j.cookie(COOKIE_NAME, 'hide', {  					path: '/', @@ -90,19 +93,46 @@ jQuery(function($j) {  				});  			}  		}, -		show_toolbar: function() { +		show_toolbar: function(animate) { +			// Set up keybindings +			$j(document).bind('keydown.djDebug', function(e) { +				if (e.keyCode == 27) { +					$j.djDebug.close(); +				} +			});  			$j('#djDebugToolbarHandle').hide(); -			$j('#djDebugToolbar').show("fast"); +			if (animate) { +				$j('#djDebugToolbar').show('fast'); +			} else { +				$j('#djDebugToolbar').show(); +			}  			$j.cookie(COOKIE_NAME, null, {  				path: '/',  				expires: -1  			}); +		}, +		toggle_arrow: function(elem) { +			var uarr = String.fromCharCode(0x25b6); +			var darr = String.fromCharCode(0x25bc); +			elem.html(elem.html() == uarr ? darr : uarr);  		}  	});  	$j(document).bind('close.djDebug', function() { -		$j(document).unbind('keydown.djDebug'); -		$j('.panelContent').hide(); -		$j('#djDebugToolbar li').removeClass("active"); +		// If a sub-panel is open, close that +		if ($j('#djDebugWindow').is(':visible')) { +			$j('#djDebugWindow').hide(); +			return; +		} +		// If a panel is open, close that +		if ($j('.panelContent').is(':visible')) { +			$j('.panelContent').hide(); +			return; +		} +		// Otherwise, just minimize the toolbar +		if ($j('#djDebugToolbar').is(':visible')) { +			$j.djDebug.hide_toolbar(true); +			return; +		}  	});  });  jQuery(function() { diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py index f12939e..a53a8d4 100644 --- a/debug_toolbar/panels/sql.py +++ b/debug_toolbar/panels/sql.py @@ -1,6 +1,6 @@  import os  import SocketServer -import time +from datetime import datetime  import traceback  import django  from django.conf import settings @@ -16,6 +16,21 @@ from debug_toolbar.panels import DebugPanel  django_path = os.path.realpath(os.path.dirname(django.__file__))  socketserver_path = os.path.realpath(os.path.dirname(SocketServer.__file__)) +# TODO:This should be set in the toolbar loader as a default and panels should +# get a copy of the toolbar object with access to its config dictionary +SQL_WARNING_THRESHOLD = getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('SQL_WARNING_THRESHOLD', 500) + +SQL_KEYWORDS = ( +    'SELECT', +    'FROM', +    'WHERE', +    'INNER JOIN', +    'LEFT OUTER JOIN', +    'ORDER BY', +    'HAVING', +    'GROUP BY', +) +  def tidy_stacktrace(strace):      """      Clean up stacktrace and remove all entries that: @@ -39,11 +54,12 @@ class DatabaseStatTracker(util.CursorDebugWrapper):      in `connection.queries`.      """      def execute(self, sql, params=()): -        start = time.time() +        start = datetime.now()          try:              return self.cursor.execute(sql, params)          finally: -            stop = time.time() +            stop = datetime.now() +            duration = ms_from_timedelta(stop - start)              stacktrace = tidy_stacktrace(traceback.extract_stack())              _params = ''              try: @@ -53,11 +69,14 @@ class DatabaseStatTracker(util.CursorDebugWrapper):              # We keep `sql` to maintain backwards compatibility              self.db.queries.append({                  'sql': self.db.ops.last_executed_query(self.cursor, sql, params), -                'time': (stop - start) * 1000, # convert to ms +                'duration': duration,                  'raw_sql': sql,                  'params': _params,                  'hash': sha_constructor(settings.SECRET_KEY + sql + _params).hexdigest(),                  'stacktrace': stacktrace, +                'start_time': start, +                'stop_time': stop, +                'is_slow': (duration > SQL_WARNING_THRESHOLD)              })  util.CursorDebugWrapper = DatabaseStatTracker @@ -77,14 +96,14 @@ class SQLDebugPanel(DebugPanel):          return 'SQL'      def nav_subtitle(self): -        self._sql_time = sum(map(lambda q: float(q['time']), connection.queries)) +        self._sql_time = sum([q['duration'] for q in connection.queries[self._offset:]])          num_queries = len(connection.queries) - self._offset          return "%d %s in %.2fms" % (              num_queries,              (num_queries == 1) and 'query' or 'queries',              self._sql_time          ) -     +      def title(self):          return 'SQL Queries' @@ -93,8 +112,15 @@ class SQLDebugPanel(DebugPanel):      def content(self):          sql_queries = connection.queries[self._offset:] +        width_ratio_tally = 0          for query in sql_queries:              query['sql'] = reformat_sql(query['sql']) +            try: +                query['width_ratio'] = (query['duration'] / self._sql_time) * 100 +            except ZeroDivisionError: +                query['width_ratio'] = 0 +            query['start_offset'] = width_ratio_tally +            width_ratio_tally += query['width_ratio']          context = {              'queries': sql_queries, @@ -103,22 +129,14 @@ class SQLDebugPanel(DebugPanel):          }          return render_to_string('debug_toolbar/panels/sql.html', context) +def ms_from_timedelta(td): +    """ +    Given a timedelta object, returns a float representing milliseconds +    """ +    return (td.seconds * 1000) + (td.microseconds / 1000.0) +  def reformat_sql(sql): -    sql = sql.replace(',', ', ') -    sql = sql.replace('SELECT ', 'SELECT\n\t') -    sql = sql.replace(' FROM ', '\nFROM\n\t') -    sql = sql.replace(' WHERE ', '\nWHERE\n\t') -    sql = sql.replace(' INNER JOIN', '\n\tINNER JOIN') -    sql = sql.replace(' LEFT OUTER JOIN' , '\n\tLEFT OUTER JOIN') -    sql = sql.replace(' ORDER BY ', '\nORDER BY\n\t') -    sql = sql.replace(' HAVING ', '\nHAVING\n\t') -    sql = sql.replace(' GROUP BY ', '\nGROUP BY\n\t') -    # Use Pygments to highlight SQL if it's available -    try: -        from pygments import highlight -        from pygments.lexers import SqlLexer -        from pygments.formatters import HtmlFormatter -        sql = highlight(sql, SqlLexer(), HtmlFormatter()) -    except ImportError: -        pass +    for kwd in SQL_KEYWORDS: +        sql = sql.replace(kwd, '<strong>%s</strong>' % (kwd,))      return sql + diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html index b80daef..dc8ccf9 100644 --- a/debug_toolbar/templates/debug_toolbar/base.html +++ b/debug_toolbar/templates/debug_toolbar/base.html @@ -56,7 +56,9 @@  					<h3>{{ panel.title|safe }}</h3>  				</div>  				<div class="djDebugPanelContent"> -					{{ panel.content|safe }} +				    <div class="scroll"> +				        {{ panel.content|safe }} +				    </div>  				</div>  			</div>  		{% endif %} diff --git a/debug_toolbar/templates/debug_toolbar/panels/headers.html b/debug_toolbar/templates/debug_toolbar/panels/headers.html index 3aafb3e..f251056 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/headers.html +++ b/debug_toolbar/templates/debug_toolbar/panels/headers.html @@ -1,19 +1,17 @@  {% load i18n %} -<div class="boxed"> -	<table> -		<thead> -			<tr> -				<th>{% trans "Key" %}</th> -				<th>{% trans "Value" %}</th> +<table> +	<thead> +		<tr> +			<th>{% trans "Key" %}</th> +			<th>{% trans "Value" %}</th> +		</tr> +	</thead> +	<tbody> +		{% for key, value in headers.iteritems %} +			<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +				<td>{{ key|escape }}</td> +				<td>{{ value|escape }}</td>  			</tr> -		</thead> -		<tbody> -			{% for key, value in headers.iteritems %} -				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -					<td>{{ key|escape }}</td> -					<td>{{ value|escape }}</td> -				</tr> -			{% endfor %} -		</tbody> -	</table> -</div>
\ No newline at end of file +		{% endfor %} +	</tbody> +</table> diff --git a/debug_toolbar/templates/debug_toolbar/panels/logger.html b/debug_toolbar/templates/debug_toolbar/panels/logger.html index 736c676..5e8b652 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/logger.html +++ b/debug_toolbar/templates/debug_toolbar/panels/logger.html @@ -1,27 +1,26 @@  {% load i18n %} -<div class="boxed"> -	{% if records %} -		<table> -			<thead> -				<tr> -					<th>{% trans "Level" %}</th> -					<th>{% trans "Time" %}</th> -					<th>{% trans "Message" %}</th> -					<th>{% trans "Location" %}</th> +{% if records %} +	<table> +		<thead> +			<tr> +				<th>{% trans "Level" %}</th> +				<th>{% trans "Time" %}</th> +				<th>{% trans "Message" %}</th> +				<th>{% trans "Location" %}</th> +			</tr> +		</thead> +		<tbody> +			{% for record in records %} +				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +					<td>{{ record.level }}</td> +					<td>{{ record.time|date:"h:i:s m/d/Y" }}</td> +					<td>{{ record.message }}</td> +					<td>{{ record.file }}:{{ record.line }}</td>  				</tr> -			</thead> -			<tbody> -				{% for record in records %} -					<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -						<td>{{ record.level }}</td> -						<td>{{ record.time|date:"h:i:s m/d/Y" }}</td> -						<td>{{ record.message }}</td> -						<td>{{ record.file }}:{{ record.line }}</td> -					</tr> -				{% endfor %} -			</tbody> -		</table> -	{% else %} -		<p>{% trans "No messages logged" %}.</p> -	{% endif %} -</div>
\ No newline at end of file +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>{% trans "No messages logged" %}.</p> +{% endif %} + diff --git a/debug_toolbar/templates/debug_toolbar/panels/request_vars.html b/debug_toolbar/templates/debug_toolbar/panels/request_vars.html index 7f5e33f..3fdbf74 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/request_vars.html +++ b/debug_toolbar/templates/debug_toolbar/panels/request_vars.html @@ -1,104 +1,96 @@  {% load i18n %}  <h4>COOKIES Variables</h4> -<div class="boxed"> -	{% if cookies %} -		<table> -			<colgroup> -				<col style="width:20%"/> -				<col/> -			</colgroup> -			<thead> -				<tr> -					<th>{% trans "Variable" %}</th> -					<th>{% trans "Value" %}</th> +{% if cookies %} +	<table> +		<colgroup> +			<col style="width:20%"/> +			<col/> +		</colgroup> +		<thead> +			<tr> +				<th>{% trans "Variable" %}</th> +				<th>{% trans "Value" %}</th> +			</tr> +		</thead> +		<tbody> +			{% for key, value in cookies %} +				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +					<td>{{ key|escape }}</td> +					<td>{{ value|escape }}</td>  				</tr> -			</thead> -			<tbody> -				{% for key, value in cookies %} -					<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -						<td>{{ key|escape }}</td> -						<td>{{ value|escape }}</td> -					</tr> -				{% endfor %} -			</tbody> -		</table> -	{% else %} -		<p>{% trans "No COOKIE data" %}</p> -	{% endif %} -</div> +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>{% trans "No COOKIE data" %}</p> +{% endif %}  <h4>SESSION Variables</h4> -<div class="boxed"> -	{% if session %} -		<table> -			<colgroup> -				<col style="width:20%"/> -				<col/> -			</colgroup> -			<thead> -				<tr> -					<th>{% trans "Variable" %}</th> -					<th>{% trans "Value" %}</th> +{% if session %} +	<table> +		<colgroup> +			<col style="width:20%"/> +			<col/> +		</colgroup> +		<thead> +			<tr> +				<th>{% trans "Variable" %}</th> +				<th>{% trans "Value" %}</th> +			</tr> +		</thead> +		<tbody> +			{% for key, value in session %} +				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +					<td>{{ key|escape }}</td> +					<td>{{ value|escape }}</td>  				</tr> -			</thead> -			<tbody> -				{% for key, value in session %} -					<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -						<td>{{ key|escape }}</td> -						<td>{{ value|escape }}</td> -					</tr> -				{% endfor %} -			</tbody> -		</table> -	{% else %} -		<p>{% trans "No SESSION data" %}</p> -	{% endif %} -</div> +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>{% trans "No SESSION data" %}</p> +{% endif %}  <h4>GET Variables</h4> -<div class="boxed"> -	{% if get %} -		<table> -			<thead> -				<tr> -					<th>{% trans "Variable" %}</th> -					<th>{% trans "Value" %}</th> +{% if get %} +	<table> +		<thead> +			<tr> +				<th>{% trans "Variable" %}</th> +				<th>{% trans "Value" %}</th> +			</tr> +		</thead> +		<tbody> +			{% for key, value in get %} +				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +					<td>{{ key|escape }}</td> +					<td>{{ value|join:", "|escape }}</td>  				</tr> -			</thead> -			<tbody> -				{% for key, value in get %} -					<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -						<td>{{ key|escape }}</td> -						<td>{{ value|join:", "|escape }}</td> -					</tr> -				{% endfor %} -			</tbody> -		</table> -	{% else %} -		<p>{% trans "No GET data" %}</p> -	{% endif %} -</div> +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>{% trans "No GET data" %}</p> +{% endif %}  <h4>POST Variables</h4> -<div class="boxed"> -	{% if post %} -		<table> -			<thead> -				<tr> -					<th>{% trans "Variable" %}</th> -					<th>{% trans "Value" %}</th> +{% if post %} +	<table> +		<thead> +			<tr> +				<th>{% trans "Variable" %}</th> +				<th>{% trans "Value" %}</th> +			</tr> +		</thead> +		<tbody> +			{% for key, value in post %} +				<tr class="{% cycle 'row1' 'row2' %}"> +					<td>{{ key|escape }}</td> +					<td>{{ value|join:", "|escape }}</td>  				</tr> -			</thead> -			<tbody> -				{% for key, value in post %} -					<tr class="{% cycle 'row1' 'row2' %}"> -						<td>{{ key|escape }}</td> -						<td>{{ value|join:", "|escape }}</td> -					</tr> -				{% endfor %} -			</tbody> -		</table> -	{% else %} -		<p>{% trans "No POST data" %}</p> -	{% endif %} -</div>
\ No newline at end of file +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>{% trans "No POST data" %}</p> +{% endif %}
\ No newline at end of file diff --git a/debug_toolbar/templates/debug_toolbar/panels/settings_vars.html b/debug_toolbar/templates/debug_toolbar/panels/settings_vars.html index 6d9cf2a..99c43b6 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/settings_vars.html +++ b/debug_toolbar/templates/debug_toolbar/panels/settings_vars.html @@ -1,19 +1,17 @@  {% load i18n %} -<div class="boxed"> -	<table> -		<thead> -			<tr> -				<th>{% trans "Setting" %}</th> -				<th>{% trans "Value" %}</th> +<table> +	<thead> +		<tr> +			<th>{% trans "Setting" %}</th> +			<th>{% trans "Value" %}</th> +		</tr> +	</thead> +	<tbody> +		{% for var in settings.items|dictsort:"0" %} +			<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +				<td>{{ var.0 }}</td> +				<td><code>{{ var.1|pprint }}</code></td>  			</tr> -		</thead> -		<tbody> -			{% for var in settings.items|dictsort:"0" %} -				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -					<td>{{ var.0 }}</td> -					<td><code>{{ var.1|pprint }}</code></td> -				</tr> -			{% endfor %} -		</tbody> -	</table> -</div>
\ No newline at end of file +		{% endfor %} +	</tbody> +</table> diff --git a/debug_toolbar/templates/debug_toolbar/panels/signals.html b/debug_toolbar/templates/debug_toolbar/panels/signals.html index 2b95d52..d6d681c 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/signals.html +++ b/debug_toolbar/templates/debug_toolbar/panels/signals.html @@ -1,21 +1,19 @@  {% load i18n %} -<div class="boxed"> -	<table> -		<thead> -			<tr> -				<th>{% trans "Signal" %}</th> -				<th>Providing Args</th> -				<th>Receivers</th> +<table> +	<thead> +		<tr> +			<th>{% trans "Signal" %}</th> +			<th>Providing Args</th> +			<th>Receivers</th> +		</tr> +	</thead> +	<tbody> +		{% for name, signal, receivers in signals %} +			<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +				<td>{{ name|escape }}</td> +				<td>{{ signal.providing_args|join:", " }}</td> +				<td>{{ receivers|join:", " }}</td>  			</tr> -		</thead> -		<tbody> -			{% for name, signal, receivers in signals %} -				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -					<td>{{ name|escape }}</td> -					<td>{{ signal.providing_args|join:", " }}</td> -					<td>{{ receivers|join:", " }}</td> -				</tr> -			{% endfor %} -		</tbody> -	</table> -</div>
\ No newline at end of file +		{% endfor %} +	</tbody> +</table> diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html index 8d1fefc..9c8bfa6 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html @@ -1,51 +1,54 @@  {% load i18n %} -<div class="boxed"> -	<table> -		<thead> -			<tr> -				<th>{% trans "Time" %} (ms)</th> -				<th>{% trans "Action" %}</th> -				<th>Stacktrace</th> -				<th>Query</th> -			</tr> -		</thead> -		<tbody> -			{% for query in queries %} -				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -					<td>{{ query.time|floatformat:"2" }}</td> -					<td> -					{% if query.params %} -						<a class="remoteCall" href="/__debug__/sql_select/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&time={{ query.time|floatformat:"2"|urlencode }}&hash={{ query.hash }}">SELECT</a> -						<a class="remoteCall" href="/__debug__/sql_explain/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&time={{ query.time|floatformat:"2"|urlencode }}&hash={{ query.hash }}">EXPLAIN</a> -						{% if is_mysql %} -							<a class="remoteCall" href="/__debug__/sql_profile/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&time={{ query.time|floatformat:"2"|urlencode }}&hash={{ query.hash }}">PROFILE</a> -						{% endif %} +<table> +	<thead> +		<tr> +			<th>{% trans "Time" %} (ms)</th> +			<th>{% trans "Action" %}</th> +			<th>Stacktrace</th> +			<th>Query</th> +		</tr> +	</thead> +	<tbody> +		{% for query in queries %} +			<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +				<td>{{ query.duration|floatformat:"2" }}</td> +				<td> +				{% if query.params %} +					<a class="remoteCall" href="/__debug__/sql_select/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">SELECT</a> +					<a class="remoteCall" href="/__debug__/sql_explain/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">EXPLAIN</a> +					{% if is_mysql %} +						<a class="remoteCall" href="/__debug__/sql_profile/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">PROFILE</a>  					{% endif %} -					</td> -					<td> -						{% if query.stacktrace %} -						<div class="djSQLShowStacktraceDiv"><a class="djSQLShowStacktrace" href="#">Toggle Stacktrace</a></div> -						<div class="djSQLHideStacktraceDiv" style="display:none;"> -							<table> +				{% endif %} +				</td> +				<td> +					{% if query.stacktrace %} +					<div class="djSQLShowStacktraceDiv"><a class="djSQLShowStacktrace" href="#">Toggle Stacktrace</a></div> +					<div class="djSQLHideStacktraceDiv" style="display:none;"> +						<table> +							<tr> +								<th>{% trans "Line" %}</th> +								<th>{% trans "Method" %}</th> +								<th>{% trans "File" %}</th> +							</tr> +							{% for file, line, method in query.stacktrace %}  								<tr> -									<th>{% trans "Line" %}</th> -									<th>{% trans "Method" %}</th> -									<th>{% trans "File" %}</th> +									<td>{{ line }}</td> +									<td><pre>{{ method|escape }}<pre></td> +									<td><pre>{{ file|escape }}</pre></td>  								</tr> -								{% for file, line, method in query.stacktrace %} -									<tr> -										<td>{{ line }}</td> -										<td><pre>{{ method|escape }}<pre></td> -										<td><pre>{{ file|escape }}</pre></td> -									</tr> -								{% endfor %} -							</table> -						</div> -						{% endif %} -					</td> -					<td class="syntax">{{ query.sql|safe }}</td> -				</tr> -			{% endfor %} -		</tbody> -	</table> -</div>
\ No newline at end of file +							{% endfor %} +						</table> +					</div> +					{% endif %} +				</td> +				<td class="syntax"> +					<div class="djDebugSqlWrap"> +						<div class="djDebugSql">{{ query.sql|safe }}</div> +						<span class="djDebugLineChart{% if query.is_slow %} djDebugLineChartWarning{% endif %}" style="width:{{ query.width_ratio }}%; left:{{ query.start_offset }}%;"</span> +					</div> +				</td> +			</tr> +		{% endfor %} +	</tbody> +</table> diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql_explain.html b/debug_toolbar/templates/debug_toolbar/panels/sql_explain.html index 38249b3..a21ec59 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql_explain.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql_explain.html @@ -6,9 +6,9 @@  <div class="djDebugPanelContent">  	<dl>  		<dt>{% trans "Executed SQL" %}</dt> -		<dd><pre>{{ sql|safe }}</pre></dd> +		<dd>{{ sql|safe }}</dd>  		<dt>{% trans "Time" %}</dt> -		<dd>{{ time }} ms</dd> +		<dd>{{ duration }} ms</dd>  	</dl>  	<table>  		<thead> diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql_profile.html b/debug_toolbar/templates/debug_toolbar/panels/sql_profile.html index 7df65da..a15574e 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql_profile.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql_profile.html @@ -4,28 +4,35 @@  	<h3>SQL Profiled</h3>  </div>  <div class="djDebugPanelContent"> -	<dl> -		<dt>{% trans "Executed SQL" %}</dt> -		<dd><pre>{{ sql|safe }}</pre></dd> -		<dt>{% trans "Time" %}</dt> -		<dd>{{ time }} ms</dd> -	</dl> -	<table> -		<thead> -			<tr> -				{% for h in headers %} -					<th>{{ h|upper }}</th> -				{% endfor %} -			</tr> -		</thead> -		<tbody> -			{% for row in result %} -				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -					{% for column in row %} -						<td>{{ column|escape }}</td> +	{% if result %} +		<dl> +			<dt>{% trans "Executed SQL" %}</dt> +			<dd>{{ sql|safe }}</dd> +			<dt>{% trans "Time" %}</dt> +			<dd>{{ duration }} ms</dd> +		</dl> +		<table> +			<thead> +				<tr> +					{% for h in headers %} +						<th>{{ h|upper }}</th>  					{% endfor %}  				</tr> -			{% endfor %} -		</tbody> -	</table> +			</thead> +			<tbody> +				{% for row in result %} +					<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +						{% for column in row %} +							<td>{{ column|escape }}</td> +						{% endfor %} +					</tr> +				{% endfor %} +			</tbody> +		</table> +	{% else %} +		<dl> +			<dt>{% trans 'Error' %}</dt> +			<dd>{{ result_error }}</dd> +		</dl> +	{% endif %}  </div> diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql_select.html b/debug_toolbar/templates/debug_toolbar/panels/sql_select.html index e4d6027..66835c8 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql_select.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql_select.html @@ -6,9 +6,9 @@  <div class="djDebugPanelContent">  	<dl>  		<dt>{% trans "Executed SQL" %}</dt> -		<dd><pre>{{ sql|safe }}</pre></dd> +		<dd>{{ sql|safe }}</dd>  		<dt>{% trans "Time" %}</dt> -		<dd>{{ time }} ms</dd> +		<dd>{{ duration }} ms</dd>  	</dl>  	{% if result %}  	<table> diff --git a/debug_toolbar/templates/debug_toolbar/panels/template_source.html b/debug_toolbar/templates/debug_toolbar/panels/template_source.html index dd23fa3..192d1af 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/template_source.html +++ b/debug_toolbar/templates/debug_toolbar/panels/template_source.html @@ -4,11 +4,5 @@  	<h3>Template Source: <code>{{ template_name }}</code></h3>  </div>  <div class="djDebugPanelContent"> -	<div class="panelScrollWrap"> -		<div class="panelScrollContent"> -			<div class="boxed"> -				{{ source }} -			</div> -		</div> -	</div> -</div>
\ No newline at end of file +	{{ source }} +</div> diff --git a/debug_toolbar/templates/debug_toolbar/panels/templates.html b/debug_toolbar/templates/debug_toolbar/panels/templates.html index d4e18b5..1158abe 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/templates.html +++ b/debug_toolbar/templates/debug_toolbar/panels/templates.html @@ -1,6 +1,5 @@  {% load i18n %}  <h4>Template path{{ template_dirs|length|pluralize }}</h4> -<div class="boxed">  {% if template_dirs %}  	<ol>  	{% for template in template_dirs %} @@ -10,39 +9,34 @@  {% else %}  	<p>None</p>  {% endif %} -</div>  <h4>{% trans "Template" %}{{ templates|length|pluralize }}</h4> -<div class="boxed"> -	{% if templates %} -	<dl> -	{% for template in templates %} -		<dt><strong><a class="remoteCall" href="/__debug__/template_source/?template={{ template.template.name }}">{{ template.template.name|addslashes }}</a></strong></dt> -		<dd><samp>{{ template.template.origin_name|addslashes }}</samp></dd> -		<dd> -			<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext">Toggle Context</a></div> -			<div class="djTemplateHideContextDiv" style="display:none;"><pre>{{ template.context }}</pre></div> -		</dd> -	{% endfor %} -	</dl> -	{% else %} -		<p>None</p> -	{% endif %} -</div> +{% if templates %} +<dl> +{% for template in templates %} +	<dt><strong><a class="remoteCall toggleTemplate" href="/__debug__/template_source/?template={{ template.template.name }}">{{ template.template.name|addslashes }}</a></strong></dt> +	<dd><samp>{{ template.template.origin_name|addslashes }}</samp></dd> +	<dd> +		<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext"><span class="toggleArrow">▶</span> Toggle Context</a></div> +		<div class="djTemplateHideContextDiv" style="display:none;"><pre>{{ template.context }}</pre></div> +	</dd> +{% endfor %} +</dl> +{% else %} +	<p>None</p> +{% endif %}  <h4>Context processor{{ context_processors|length|pluralize }}</h4> -<div class="boxed"> -	{% if context_processors %} -	<dl> -	{% for key, value in context_processors.iteritems %} -		<dt><strong>{{ key|escape }}</strong></dt> -		<dd> -			<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext">Toggle Context</a></div> -			<div class="djTemplateHideContextDiv" style="display:none;"><pre>{{ value|escape }}</pre></div> -		</dd> -	{% endfor %} -	</dl> -	{% else %} -		<p>None</p> -	{% endif %} -</div> +{% if context_processors %} +<dl> +{% for key, value in context_processors.iteritems %} +	<dt><strong>{{ key|escape }}</strong></dt> +	<dd> +		<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext"><span class="toggleArrow">▶</span> Toggle Context</a></div> +		<div class="djTemplateHideContextDiv" style="display:none;"><pre>{{ value|escape }}</pre></div> +	</dd> +{% endfor %} +</dl> +{% else %} +	<p>None</p> +{% endif %} diff --git a/debug_toolbar/templates/debug_toolbar/panels/timer.html b/debug_toolbar/templates/debug_toolbar/panels/timer.html index d25f051..f267de1 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/timer.html +++ b/debug_toolbar/templates/debug_toolbar/panels/timer.html @@ -1,23 +1,21 @@  {% load i18n %} -<div class="boxed"> -	<table> -		<colgroup> -			<col style="width:20%"/> -			<col/> -		</colgroup> -		<thead> -			<tr> -				<th>{% trans "Resource" %}</th> -				<th>{% trans "Value" %}</th> +<table> +	<colgroup> +		<col style="width:20%"/> +		<col/> +	</colgroup> +	<thead> +		<tr> +			<th>{% trans "Resource" %}</th> +			<th>{% trans "Value" %}</th> +		</tr> +	</thead> +	<tbody> +		{% for key, value in rows %} +			<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> +				<td>{{ key|escape }}</td> +				<td>{{ value|escape }}</td>  			</tr> -		</thead> -		<tbody> -			{% for key, value in rows %} -				<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> -					<td>{{ key|escape }}</td> -					<td>{{ value|escape }}</td> -				</tr> -			{% endfor %} -		</tbody> -	</table> -</div>
\ No newline at end of file +		{% endfor %} +	</tbody> +</table> diff --git a/debug_toolbar/templates/debug_toolbar/redirect.html b/debug_toolbar/templates/debug_toolbar/redirect.html index d0d9b35..068fe8c 100644 --- a/debug_toolbar/templates/debug_toolbar/redirect.html +++ b/debug_toolbar/templates/debug_toolbar/redirect.html @@ -6,11 +6,7 @@  <h1>HttpResponseRedirect</h1>  <p>Location: <a href="{{ redirect_to|urlencode }}">{{ redirect_to }}</a></p>  <p class="notice"> -	{% trans "The Django Debug Toolbar has intercepted a redirect to the above URL for -	debug viewing purposes.  You can click the above link to continue with the -	redirect as normal.  If you'd like to disable this feature, set the" %} -	<code>DEBUG_TOOLBAR_CONFIG</code> dictionary's key -	<code>INTERCEPT_REDIRECTS</code> to <code>False</code>." %} +	{% trans "The Django Debug Toolbar has intercepted a redirect to the above URL for debug viewing purposes.  You can click the above link to continue with the redirect as normal.  If you'd like to disable this feature, set the <code>DEBUG_TOOLBAR_CONFIG</code> dictionary's key <code>INTERCEPT_REDIRECTS</code> to <code>False</code>." %}  </p>  </body>  </html> diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py index 9123a00..3a8cb79 100644 --- a/debug_toolbar/views.py +++ b/debug_toolbar/views.py @@ -33,7 +33,7 @@ def sql_select(request):      Expected GET variables:          sql: urlencoded sql with positional arguments          params: JSON encoded parameter values -        time: time for SQL to execute passed in from toolbar just for redisplay +        duration: time for SQL to execute passed in from toolbar just for redisplay          hash: the hash of (secret + sql + params) for tamper checking      """      from debug_toolbar.panels.sql import reformat_sql @@ -52,7 +52,7 @@ def sql_select(request):          context = {              'result': result,              'sql': reformat_sql(cursor.db.ops.last_executed_query(cursor, sql, params)), -            'time': request.GET.get('time', 0.0), +            'duration': request.GET.get('duration', 0.0),              'headers': headers,          }          return render_to_response('debug_toolbar/panels/sql_select.html', context) @@ -65,7 +65,7 @@ def sql_explain(request):      Expected GET variables:          sql: urlencoded sql with positional arguments          params: JSON encoded parameter values -        time: time for SQL to execute passed in from toolbar just for redisplay +        duration: time for SQL to execute passed in from toolbar just for redisplay          hash: the hash of (secret + sql + params) for tamper checking      """      from debug_toolbar.panels.sql import reformat_sql @@ -84,7 +84,7 @@ def sql_explain(request):          context = {              'result': result,              'sql': reformat_sql(cursor.db.ops.last_executed_query(cursor, sql, params)), -            'time': request.GET.get('time', 0.0), +            'duration': request.GET.get('duration', 0.0),              'headers': headers,          }          return render_to_response('debug_toolbar/panels/sql_explain.html', context) @@ -97,7 +97,7 @@ def sql_profile(request):      Expected GET variables:          sql: urlencoded sql with positional arguments          params: JSON encoded parameter values -        time: time for SQL to execute passed in from toolbar just for redisplay +        duration: time for SQL to execute passed in from toolbar just for redisplay          hash: the hash of (secret + sql + params) for tamper checking      """      from debug_toolbar.panels.sql import reformat_sql @@ -109,21 +109,28 @@ def sql_profile(request):      if sql.lower().strip().startswith('select'):          params = simplejson.loads(params)          cursor = connection.cursor() -        cursor.execute("SET PROFILING=1") # Enable profiling -        cursor.execute(sql, params) # Execute SELECT -        cursor.execute("SET PROFILING=0") # Disable profiling -        # The Query ID should always be 1 here but I'll subselect to get the last one just in case... -        cursor.execute("SELECT * FROM information_schema.profiling WHERE query_id=(SELECT query_id FROM information_schema.profiling ORDER BY query_id DESC LIMIT 1)") -        headers = [d[0] for d in cursor.description] -        result = cursor.fetchall() +        result = None +        headers = None +        result_error = None +        try: +            cursor.execute("SET PROFILING=1") # Enable profiling +            cursor.execute(sql, params) # Execute SELECT +            cursor.execute("SET PROFILING=0") # Disable profiling +            # The Query ID should always be 1 here but I'll subselect to get the last one just in case... +            cursor.execute("SELECT * FROM information_schema.profiling WHERE query_id=(SELECT query_id FROM information_schema.profiling ORDER BY query_id DESC LIMIT 1)") +            headers = [d[0] for d in cursor.description] +            result = cursor.fetchall() +        except: +            result_error = "Profiling is either not available or not supported by your database."          cursor.close()          context = {              'result': result, +            'result_error': result_error,              'sql': reformat_sql(cursor.db.ops.last_executed_query(cursor, sql, params)), -            'time': request.GET.get('time', 0.0), +            'duration': request.GET.get('duration', 0.0),              'headers': headers,          } -        return render_to_response('debug_toolbar/panels/sql_explain.html', context) +        return render_to_response('debug_toolbar/panels/sql_profile.html', context)      raise InvalidSQLError("Only 'select' queries are allowed.")  def template_source(request): | 
