aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/panels/sql
diff options
context:
space:
mode:
authorAymeric Augustin2013-11-24 17:30:49 +0100
committerAymeric Augustin2013-11-24 17:30:49 +0100
commit57a6e261c2768503e1401f99cefd4470c8dc5e8f (patch)
treead0f1553d0155988701b1d63f0f4438ae127bcab /debug_toolbar/panels/sql
parent3d72c1fa927f129b2a79ea3496cce3262516705b (diff)
downloaddjango-debug-toolbar-57a6e261c2768503e1401f99cefd4470c8dc5e8f.tar.bz2
Update all panels to follow the public API.
Diffstat (limited to 'debug_toolbar/panels/sql')
-rw-r--r--debug_toolbar/panels/sql/panel.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/debug_toolbar/panels/sql/panel.py b/debug_toolbar/panels/sql/panel.py
index 3bfbe60..f4133db 100644
--- a/debug_toolbar/panels/sql/panel.py
+++ b/debug_toolbar/panels/sql/panel.py
@@ -49,10 +49,6 @@ class SQLPanel(Panel):
Panel that displays information about the SQL queries run while processing
the request.
"""
- name = 'SQL'
- template = 'debug_toolbar/panels/sql.html'
- has_content = True
-
def __init__(self, *args, **kwargs):
super(SQLPanel, self).__init__(*args, **kwargs)
self._offset = dict((k, len(connections[k].queries)) for k in connections)
@@ -104,26 +100,31 @@ class SQLPanel(Panel):
self._sql_time += kwargs['duration']
self._num_queries += 1
- @classmethod
- def get_urls(cls):
- return patterns('debug_toolbar.panels.sql.views', # noqa
- url(r'^sql_select/$', 'sql_select', name='sql_select'),
- url(r'^sql_explain/$', 'sql_explain', name='sql_explain'),
- url(r'^sql_profile/$', 'sql_profile', name='sql_profile'),
- )
+ # Implement the Panel API
- def nav_title(self):
- return _('SQL')
+ nav_title = _('SQL')
+ @property
def nav_subtitle(self):
return __("%d query in %.2fms", "%d queries in %.2fms",
self._num_queries) % (self._num_queries, self._sql_time)
+ @property
def title(self):
count = len(self._databases)
- return __('SQL Queries from %(count)d connection',
- 'SQL Queries from %(count)d connections',
- count) % dict(count=count)
+ return __('SQL queries from %(count)d connection',
+ 'SQL queries from %(count)d connections',
+ count) % {'count': count}
+
+ template = 'debug_toolbar/panels/sql.html'
+
+ @classmethod
+ def get_urls(cls):
+ return patterns('debug_toolbar.panels.sql.views', # noqa
+ url(r'^sql_select/$', 'sql_select', name='sql_select'),
+ url(r'^sql_explain/$', 'sql_explain', name='sql_explain'),
+ url(r'^sql_profile/$', 'sql_profile', name='sql_profile'),
+ )
def enable_instrumentation(self):
# This is thread-safe because database connections are thread-local.