aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave McLain2011-04-21 20:12:42 -0500
committerDave McLain2011-04-21 20:12:42 -0500
commitdfee3848866f2193576d2bdd44f0c8bcd10c63a4 (patch)
tree07f8fa1da27bc68257cb9e5dc18f036c1670521d
parentf3a9b2b58bb468f65a5d5de2a5f8cb4b5ffe8b67 (diff)
downloaddjango-debug-toolbar-dfee3848866f2193576d2bdd44f0c8bcd10c63a4.tar.bz2
Creating a profiling panel from the version panel for basic stuff
-rw-r--r--debug_toolbar/panels/profiling.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py
new file mode 100644
index 0000000..302f444
--- /dev/null
+++ b/debug_toolbar/panels/profiling.py
@@ -0,0 +1,59 @@
+import sys
+
+import django
+from django.conf import settings
+from django.template.loader import render_to_string
+from django.utils.translation import ugettext_lazy as _
+
+import debug_toolbar
+from debug_toolbar.panels import DebugPanel
+
+
+class VersionDebugPanel(DebugPanel):
+ """
+ Panel that displays the Django version.
+ """
+ name = 'Profiling'
+ has_content = True
+
+ def nav_title(self):
+ return _('Versions')
+
+ def nav_subtitle(self):
+ return 'Django %s' % django.get_version()
+
+ def url(self):
+ return ''
+
+ def title(self):
+ return _('Versions')
+
+ def content(self):
+ versions = {}
+ for app in settings.INSTALLED_APPS + ['django']:
+ name = app.split('.')[-1].replace('_', ' ').capitalize()
+ __import__(app)
+ app = sys.modules[app]
+ if hasattr(app, 'get_version'):
+ get_version = app.get_version
+ if callable(get_version):
+ version = get_version()
+ else:
+ version = get_version
+ elif hasattr(app, 'VERSION'):
+ version = app.VERSION
+ elif hasattr(app, '__version__'):
+ version = app.__version__
+ else:
+ continue
+ if isinstance(version, (list, tuple)):
+ version = '.'.join(str(o) for o in version)
+ versions[name] = version
+
+ context = self.context.copy()
+ context.update({
+ 'versions': versions,
+ 'paths': sys.path,
+ })
+
+ return render_to_string('debug_toolbar/panels/versions.html', context)