django-queryinspect
Django Query Inspector
What it is and what it does
Django Query Inspector is middleware that intercepts and analyzes SQL queries executed during each web request. It logs aggregate statistics—total query count, execution time, and duplicate detection—and optionally adds these metrics to HTTP response headers for easier debugging without server log inspection.
The package detects duplicate queries by normalizing SQL statements to ignore integer values, targeting the common Django pattern where N+1 queries occur due to missing prefetch_related or select_related calls. It can also include Python tracebacks showing where each duplicate query originated, helping developers identify the source code responsible. Configuration options allow fine-tuning of what gets logged, thresholds for query time alerts, and filtering of tracebacks to project-specific paths.
Use it for:
- Identify N+1 query problems during development by spotting repeated SQL patterns in request logs.
- Monitor query performance during testing to catch regressions in SQL execution time across requests.
- Debug slow requests by examining query counts and timing in response headers without parsing server logs.
- Locate inefficient serialization or view logic by correlating duplicate query tracebacks to application code.
- Profile Django views in development to understand SQL behavior before optimization.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Django middleware that logs and reports SQL query statistics for each web request, including query counts, execution time, and detection of duplicate queries.
No. The package is abandoned (last commit 2020-02-27, no releases since 2019-09-10) and will not receive security updates or Django compatibility fixes. For modern Django projects, consider actively maintained alternatives like django-debug-toolbar or django-silk, which offer similar query inspection with ongoing support.
Install
django-queryinspect on PyPI
pip
pip install django-queryinspectuv
uv add django-queryinspectpoetry
poetry add django-queryinspectInstalling django-queryinspect
Before you install
Low install friction with a single runtime dependency on Django. However, the package is abandoned—last release was 2019-09-10 and last commit 2020-02-27. No active maintenance means security issues or Django compatibility problems will not be addressed.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and proprietary projects.
Quickstart
pip install django-queryinspect
# In Django settings.py:
MIDDLEWARE += ('qinspect.middleware.QueryInspectMiddleware',)
QUERY_INSPECT_ENABLED = True
DEBUG = True
# Configure logging to see output
LOGGING = {
'loggers': {
'qinspect': {'handlers': ['console'], 'level': 'DEBUG'},
},
}
Requires Django 1.11 or later and DEBUG = True enabled; SQL query logging does not work without DEBUG mode.
Verify before relying
- Compatibility with modern Django versions (3.2+, 4.x, 5.x) given the package's abandonment since 2020.
- Whether the heuristic for detecting duplicate queries (ignoring integer values) remains effective with current Django ORM patterns.
- Performance impact on high-traffic applications when query logging and traceback collection are enabled.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — Django |
| Maintenance | abandoned — 2,530 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 73,619/month — #14,961 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_queryinspect-1.1.0-py2-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
django-querycountDjango middleware that logs the number of…
permissive · top 15,000 on PyPI
requests-trackerA Django development middleware that collects…
permissive · top 15,000 on PyPI
django-sql-explorerA Django-based SQL query editor and business…
permissive · top 15,000 on PyPI
django-silkSilk intercepts and profiles HTTP requests,…
permissive · top 5,000 on PyPI
django-zealDetects N+1 query problems in Django…
unclear · top 15,000 on PyPI
django-cprofile-middlewareMiddleware that profiles Django view execution…
permissive · top 15,000 on PyPI
sqltapsqltap hooks into SQLAlchemy to collect and…
permissive · top 15,000 on PyPI
django-cidAssigns unique correlation IDs to incoming HTTP…
permissive · top 15,000 on PyPI
django-pgactivityProvides Django management commands and…
permissive · top 5,000 on PyPI
django-perf-recRecords and compares Django database queries…
permissive · top 15,000 on PyPI