django-zeal
Detect N+1s in your Django app
What it is and what it does
django-zeal is a Django development tool that catches N+1 query problems—situations where the same database query runs multiple times when it should run once. It monitors queries during web requests, Celery tasks, and test runs, detecting N+1s caused by missing prefetches or misuse of .defer(), .only(), and .get() methods. The tool integrates via Django middleware and signals, raising errors or logging warnings when problems are found.
It works by tracking which queries execute and how many times, with a configurable threshold for what counts as an N+1. You can allowlist specific model/field combinations, temporarily ignore sections of code, or listen to Django signals to handle detections globally. The package has no runtime dependencies and adds minimal overhead, making it practical for continuous use in development and test suites.
Use it for:
- Catch N+1 query bugs during Django test runs before code review or deployment
- Monitor Celery background tasks for database query inefficiencies using signal hooks
- Identify missing prefetch_related() calls in view code with precise file and line numbers
- Allow-list known false positives or intentional query patterns to keep test suites clean
- Debug query performance regressions by enabling full call stacks with ZEAL_SHOW_ALL_CALLERS
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Detects N+1 query problems in Django applications by monitoring database queries during web requests, Celery tasks, and tests, with configurable thresholds and allowlisting.
Yes. django-zeal is a low-friction, actively maintained tool with no dependencies that solves a real Django performance problem. Install it in development and test environments to catch N+1 queries early. The MIT license is clear, and the overhead is acceptable for non-production use. Not suitable for production deployment.
Install
django-zeal on PyPI
pip
pip install django-zealuv
uv add django-zealpoetry
poetry add django-zealInstalling django-zeal
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 21 days ago. Designed to run only in development and test environments with documented 3-5% overhead.
License in practice
MIT license (clear permissive terms). Includes attribution to original nplusone author Joshua Carp and current maintainer Tao Bojlén.
Quickstart
pip install django-zeal
# In Django settings.py (development only):
if DEBUG:
INSTALLED_APPS.append("zeal")
MIDDLEWARE.append("zeal.middleware.zeal_middleware")
# Or with a test framework:
from zeal import zeal_context
with zeal_context():
# your code here
pass
Requires Django and Python 3.9 or later. Intended for development and test environments only; not for production use.
Verify before relying
- Whether the package detects all forms of N+1 queries or only the specific patterns mentioned (missing prefetches, .defer(), .only(), .get())
- Compatibility with specific Django versions (not specified in fact sheet)
- Current test coverage and stability metrics beyond 'well-tested' claim
Package facts
| License | Copyright 2016 Joshua Carp Copyright 2024 Tao Bojlén Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),… (full text in the JSON record) (unclear) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 21 days since the last release |
| First released | |
| Downloads | 133,810/month — #11,494 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_zeal-2.2.2-py3-none-any.whl
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
nplusoneDetects n+1 query problems in Python ORMs…
unclear · top 15,000 on PyPI
django-querycountDjango middleware that logs the number of…
permissive · top 15,000 on PyPI
django-queryinspectDjango middleware that logs and reports SQL…
permissive · top 15,000 on PyPI
drf-api-loggerCaptures and logs Django REST Framework API…
permissive · top 15,000 on PyPI
django-perf-recRecords and compares Django database queries…
permissive · top 15,000 on PyPI
django-celery-resultsStores Celery task results in a Django database…
permissive · top 5,000 on PyPI
django-easy-auditLogs every CRUD operation, authentication…
copyleft · top 15,000 on PyPI
sqlalchemy-mixinsProvides Active Record-style mixins for…
permissive · top 15,000 on PyPI
pytest-celerypytest-celery is the official pytest plugin for…
permissive · top 5,000 on PyPI
django-sesA Django email backend that routes outgoing…
permissive · top 5,000 on PyPI