Skip to main content

N+1 query detection for Django

Project description

django-nplus1

N+1 query detection for Django.

Based on nplusone by Joshua Carp. Several features inspired by django-zeal by Tao Bojlen.

Quick Start

pip install django-nplus1
# settings.py
INSTALLED_APPS = [..., "django_nplus1"]
# tests.py
@pytest.mark.nplus1
class TestMyView:
    def test_list_books(self, books):
        response = client.get("/books/")  # raises NPlus1Error if view has N+1

Tests marked with @pytest.mark.nplus1 will fail if the code under test triggers an N+1 query. Fix the N+1, or use nplus1_allow() in helper functions that intentionally defer prefetching to their callers.

See examples/ for a working project and the docs for full configuration.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_nplus1-0.1.0a2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_nplus1-0.1.0a2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file django_nplus1-0.1.0a2.tar.gz.

File metadata

  • Download URL: django_nplus1-0.1.0a2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_nplus1-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 434b5b06fce943612037cc0d652266effbe744c06caa1b625e1061c78334d2ba
MD5 dc3e71a814685c3e14da78fd68e95ae0
BLAKE2b-256 8a51625d54f08dfd879c8956c8cb3330db7000f1a7d240816018dd045da56403

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_nplus1-0.1.0a2.tar.gz:

Publisher: publish.yml on oliverhaas/django-nplus1

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_nplus1-0.1.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_nplus1-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 cedbe0e44626cc4646ad59915710cc0931ec3e9093f117f68b2c1f8a7f3fd5bb
MD5 71e1f7030386d4babcad1984215f790e
BLAKE2b-256 d472314e09fcdf40c4f112ce1365e1953c9fb72089205410dab49776f9fc93f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_nplus1-0.1.0a2-py3-none-any.whl:

Publisher: publish.yml on oliverhaas/django-nplus1

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page