Extensions for Django MongoDB Backend
pip install django-mongodb-extensionsThis panel for Django Debug Toolbar provides insights into MongoDB queries executed during a request similar to how the SQL panel works for relational databases.
Features:
- View all MongoDB queries (MQL) executed during a request
- See query execution time and identify slow queries
- Re-execute read operations (aggregate) directly from the toolbar
- Explain query execution plans
- Color-coded query grouping for easy identification
- Detailed query statistics and performance metrics
First, install and configure Django Debug Toolbar by following their installation instructions.
- Add to
INSTALLED_APPSin your Django settings:
INSTALLED_APPS = [
# ...
"django_mongodb_extensions",
# ...
]- Add the MQL Panel to your debug toolbar configuration:
DEBUG_TOOLBAR_PANELS = [
"debug_toolbar.panels.history.HistoryPanel",
"debug_toolbar.panels.versions.VersionsPanel",
"debug_toolbar.panels.timer.TimerPanel",
"debug_toolbar.panels.settings.SettingsPanel",
"debug_toolbar.panels.headers.HeadersPanel",
"debug_toolbar.panels.request.RequestPanel",
# Add this:
"django_mongodb_extensions.mql_panel.MQLPanel",
"debug_toolbar.panels.templates.TemplatesPanel",
"debug_toolbar.panels.staticfiles.StaticFilesPanel",
"debug_toolbar.panels.cache.CachePanel",
"debug_toolbar.panels.signals.SignalsPanel",
"debug_toolbar.panels.redirects.RedirectsPanel",
"debug_toolbar.panels.profiling.ProfilingPanel",
]- Optional: Configure settings.
# Maximum number of documents to return when re-executing select
# queries (default is 100).
DJDT_MQL_MAX_QUERY_RESULTS = 25
# Queries slower than this threshold (in milliseconds) are highlighted
# in the debug toolbar (default is 500 ms).
DJDT_MQL_WARNING_THRESHOLD = 1000See LICENSE file for details.