Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

Updated to use latest version of the debug-toolbar library. #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions debug_toolbar_mongo/operation_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
removes = []

WANT_STACK_TRACE = getattr(settings, 'DEBUG_TOOLBAR_MONGO_STACKTRACES', True)


def _get_stacktrace():
if WANT_STACK_TRACE:
try:
Expand Down
23 changes: 13 additions & 10 deletions debug_toolbar_mongo/panel.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.template import Template, Context
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe

from debug_toolbar.panels import DebugPanel
from debug_toolbar.panels import Panel

import operation_tracker

Expand All @@ -16,11 +15,13 @@
{% endfor %}
'''

class MongoDebugPanel(DebugPanel):

class MongoDebugPanel(Panel):
"""Panel that shows information about MongoDB operations.
"""
name = 'MongoDB'
has_content = True
template = 'mongo-panel.html'

def __init__(self, *args, **kwargs):
super(MongoDebugPanel, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -66,12 +67,14 @@ def title(self):
def url(self):
return ''

def content(self):
context = self.context.copy()
context['queries'] = operation_tracker.queries
context['inserts'] = operation_tracker.inserts
context['updates'] = operation_tracker.updates
context['removes'] = operation_tracker.removes
return render_to_string('mongo-panel.html', context)
def get_stats(self):

return {
'queries': operation_tracker.queries,
'inserts': operation_tracker.inserts,
'updates': operation_tracker.updates,
'removes': operation_tracker.removes
}