Skip to main content

PyPI version Python versions Build codecov License

django-ninja-search

A lightweight decorator to add filtering, searching, and sorting support to Django Ninja view functions.


✨ Features

  • Add full-text search and ordering with a decorator
  • Optional schema-based filtering
  • Works seamlessly with Django ORM and Django Ninja

📦 Installation

pip install django-ninja-search

Or with Poetry:

poetry add django-ninja-search

🚀 Usage

1. Define your model (example)

# models.py
class Item(models.Model):
    name = models.CharField(max_length=100)
    description = models.TextField()

2. Add the decorator to your view

# views.py
from ninja import Query
from ninja_schema import Schema
from ninja_search.searching import searching

class ItemFilterSchema(Schema):
    pass  # You can define extra filters here if needed

@searching(
    filterSchema=ItemFilterSchema,
    search_fields=["name", "description"],
    sort_fields=["name", "description"],
)
def list_items(request, filters: ItemFilterSchema = Query(...)):
    return Item.objects.all()

This enables:

  • /?search=banana → filters by search text
  • /?ordering=name → sorts results

🧪 Running Tests

poetry install
poetry run pytest --cov=ninja_search --cov-report=html

Open the coverage report in your browser:

open htmlcov/index.html  # macOS
xdg-open htmlcov/index.html  # Linux

📤 Publishing

✅ Publish to Test PyPI

poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish --build -r testpypi

🚀 Publish to PyPI

poetry config repositories.pypi https://upload.pypi.org/legacy/
poetry config pypi-token.pypi <your-token-here>
poetry publish --build -r pypi

🔁 Versioning and Release

Before releasing a new version:

poetry version patch  # or minor / major
poetry build
# Publish using one of the methods above

# Tag and push
NEW_VERSION=$(poetry version -s)
git tag v$NEW_VERSION
git push origin v$NEW_VERSION
git push origin main

📚 Metadata & Compatibility

Python Versions: 3.10, 3.11, 3.12, 3.13 Django Versions: >=5.1.0 License: MIT Project URL: https://github.com/anandrnair547/django-ninja-search PyPI: https://pypi.org/project/django-ninja-search/


🤝 Contributing

We welcome contributions! See the Contributing Guide for setup instructions, test coverage tips, release workflow, and versioning guidance.


🧾 License

MIT © Anand R Nair

AI Development Setup (Optional)

This repo uses an agent-setup submodule — a shared AI agent framework with agents, workflows, and skills for Claude Code, Cursor, Copilot, and other AI tools.

After cloning, initialize it if you use AI-assisted development:

git submodule update --init --recursive

This is optional — the submodule is only needed for AI tooling. The app runs fine without it.

To pull the latest agent framework updates:

git submodule update --remote agent-setup

Metadata

Release files for django-ninja-search 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-ninja-search 0.2.0
File Size Uploaded Provenance Actions
django_ninja_search-0.2.0.tar.gz 4.0 kB With provenance Details for django_ninja_search-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-ninja-search 0.2.0
File Interpreter ABI Platform Actions
django_ninja_search-0.2.0-py3-none-any.whl Python 3 none any Details for django_ninja_search-0.2.0-py3-none-any.whl

Total release size: 8.8 kB

Release files / django_ninja_search-0.2.0.tar.gz

Download URL django_ninja_search-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e23692f147970456fd799ff46af87d68c33d0cfc731b2478e9c1295fbac36361
BLAKE2b-256 checksum
How to use checksums
178e64076bae9e2673f4b80812f5a3dfac09e45c88e8c24b550316b2ff4aa723
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 15, 2026.

Transparency log

Release files / django_ninja_search-0.2.0-py3-none-any.whl

Download URL django_ninja_search-0.2.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac5250a1fefb927248da7a8f5a465569eed325fe83f9b58a4fb8ecfae607d58b
BLAKE2b-256 checksum
How to use checksums
ca4bbca3850ea2ff6a10a8a86ce58977268f8f71aa6f069e1a132171f57534f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 15, 2026.

Transparency log

Security for django-ninja-search 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_ninja_search-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page