Skip to content

Commit ed9bca7

Browse files
committed
Add a default 'content' method, since the method is now identical on every panel
1 parent c20e83f commit ed9bca7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

debug_toolbar/panels/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from django.template.defaultfilters import slugify
2+
from django.template.loader import render_to_string
23
from debug_toolbar.middleware import DebugToolbarMiddleware
34

45

56
class DebugPanel(object):
67
"""
78
Base class for debug panels.
89
"""
9-
# name = Base
10+
# name = 'Base'
11+
# template = 'debug_toolbar/panels/base.html'
1012
has_content = False # If content returns something, set to true in subclass
1113

1214
# We'll maintain a local context instance so we can expose our template
@@ -38,7 +40,10 @@ def url(self):
3840
raise NotImplementedError
3941

4042
def content(self):
41-
raise NotImplementedError
43+
if self.has_content:
44+
context = self.context.copy()
45+
context.update(self.get_stats())
46+
return render_to_string(self.template, context)
4247

4348
def record_stats(self, stats):
4449
panel_stats = self.toolbar.stats.get(self.slug)

0 commit comments

Comments
 (0)