Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package name column added to Versions panel. #715

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions debug_toolbar/panels/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.conf import settings
from django.utils.translation import ugettext_lazy as _

from debug_toolbar.compat import import_module, OrderedDict
from debug_toolbar.compat import import_module
from debug_toolbar.panels import Panel


Expand All @@ -24,15 +24,15 @@ def nav_subtitle(self):

def process_response(self, request, response):
versions = [
('Python', '%d.%d.%d' % sys.version_info[:3]),
('Django', self.get_app_version(django)),
('Python', '', '%d.%d.%d' % sys.version_info[:3]),
('Django', '', self.get_app_version(django)),
]
if django.VERSION[:2] >= (1, 7):
versions += list(self.gen_app_versions_1_7())
else:
versions += list(self.gen_app_versions_1_6())
self.record_stats({
'versions': OrderedDict(sorted(versions, key=lambda v: v[0])),
'versions': sorted(versions, key=lambda v: v[0]),
'paths': sys.path,
})

Expand All @@ -43,15 +43,16 @@ def gen_app_versions_1_7(self):
app = app_config.module
version = self.get_app_version(app)
if version:
yield name, version
yield app.__name__, name, version

def gen_app_versions_1_6(self):
for app in list(settings.INSTALLED_APPS):
name = app.split('.')[-1].replace('_', ' ').capitalize()
package = app.split('.')[-1]
name = package.replace('_', ' ').capitalize()
app = import_module(app)
version = self.get_app_version(app)
if version:
yield name, version
yield package, name, version

def get_app_version(self, app):
if hasattr(app, 'get_version'):
Expand Down
4 changes: 3 additions & 1 deletion debug_toolbar/templates/debug_toolbar/panels/versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
<table>
<thead>
<tr>
<th>{% trans "Package" %}</th>
<th>{% trans "Name" %}</th>
<th>{% trans "Version" %}</th>
</tr>
</thead>
<tbody>
{% for package, version in versions.items %}
{% for package, name, version in versions %}
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
<td>{{ package }}</td>
<td>{{ name }}</td>
<td>{{ version }}</td>
</tr>
{% endfor %}
Expand Down