skillfed

django-zeal

Detect N+1s in your Django app

django-zeal v2.2.2 133.8K downloads/30d#11,494 on PyPI
License unclear 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) Active released

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-zeal

uv

uv add django-zeal

poetry

poetry add django-zeal

Installing 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

django n+1 query detectioncatch duplicate database queriesdjango orm performance testingprefetch missing detectiondjango query monitoringdatabase query optimization tooldjango test performance checker
django-ormperformance-testingquery-optimization

More Quality Assurance packages