--- id: django-querycount version: "0.8.3" license: MIT license_treatment: permissive maintenance: dormant --- # django-querycount — Middleware that Prints the number of DB queries to the runserver console. License: permissive · Maintenance: dormant · Downloads: 153.3K/mo ## What it is and what it does django-querycount is a Django middleware that intercepts HTTP requests during development and logs how many database queries were executed to handle each request. It prints colored, threshold-based output to the runserver console, helping developers spot performance issues early. The middleware is hardcoded to work only when DEBUG is True, making it safe for development-only use. The package offers configurable thresholds to color-code query counts (MEDIUM at 50, HIGH at 200), regex-based request and SQL pattern filtering to ignore certain paths or query types, optional duplicate query reporting, and a custom response header containing the query count. It has no runtime dependencies and integrates purely through Django's middleware stack. Use it for: - Identify query problems during local development by monitoring query counts per request. - Compare query efficiency across different request handlers to spot performance issues. - Filter out noisy middleware (e.g., health checks, admin requests) to focus on application endpoints. - Track duplicate queries to find repeated database calls that could be optimized. - Add query count metadata to HTTP response headers for integration with monitoring tools. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Django middleware that logs the number of database queries executed for each HTTP request in the runserver console, with configurable thresholds and filtering. Yes, if you are actively developing a Django application and want low-friction query profiling during local testing. The permissive MIT license and zero runtime dependencies make it easy to add. However, maintenance is dormant (last release 2023-01-05); verify compatibility with your Django and Python versions before relying on it. The high install friction is offset by the simplicity of the middleware pattern. ## Install pip install django-querycount uv add django-querycount poetry add django-querycount ## Installing django-querycount Before you install: High install friction with no runtime dependencies but requires manual middleware registration in Django settings. Maintenance is dormant—last release was 2023-01-05, though the repository remains active with a recent commit on 2024-05-29 and 408 stars. Use only if you accept infrequent updates. License in practice: MIT license (permissive) allows free use, modification, and distribution with minimal restrictions. No licensing barrier to adoption. Quickstart: pip install django-querycount # In Django settings.py, add to MIDDLEWARE: MIDDLEWARE = [ 'querycount.middleware.QueryCountMiddleware', # ... ] # Optional: configure thresholds QUERYCOUNT = { 'THRESHOLDS': {'MEDIUM': 50, 'HIGH': 200} } Requires Django project with DEBUG=True; middleware must be manually registered in MIDDLEWARE setting. Verify before relying: - Compatibility with current Django versions relative to the 2023-01-05 release date. - Whether the package works with modern Python versions beyond what the fact sheet specifies. - Whether high install friction reflects a known blocker or is typical for middleware packages. ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: high - Maintenance: dormant - Downloads: 153.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django query count logging, database query profiling middleware, django debug query counter, db query monitoring django, django performance query tracking, request query statistics django, django sql query debugging, django-middleware, query-profiling, development-tool [View on SkillFed](https://skillfed.io/packages/django-querycount) · [View on PyPI](https://pypi.org/project/django-querycount/)