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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_ninja_search-0.2.0.tar.gz.
File metadata
- Download URL: django_ninja_search-0.2.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e23692f147970456fd799ff46af87d68c33d0cfc731b2478e9c1295fbac36361
|
|
| MD5 |
0fb6434dce2d00acdde8ce419d0ba802
|
|
| BLAKE2b-256 |
178e64076bae9e2673f4b80812f5a3dfac09e45c88e8c24b550316b2ff4aa723
|
Provenance
The following attestation bundles were made for django_ninja_search-0.2.0.tar.gz:
Publisher:
publish.yml on anandrnair547/django-ninja-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_ninja_search-0.2.0.tar.gz -
Subject digest:
e23692f147970456fd799ff46af87d68c33d0cfc731b2478e9c1295fbac36361 - Sigstore transparency entry: 2174112684
- Sigstore integration time:
-
Permalink:
anandrnair547/django-ninja-search@e9d89afeb436f5e3bf28cf7d3d316df32fb322ee -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/anandrnair547
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e9d89afeb436f5e3bf28cf7d3d316df32fb322ee -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_ninja_search-0.2.0-py3-none-any.whl.
File metadata
- Download URL: django_ninja_search-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac5250a1fefb927248da7a8f5a465569eed325fe83f9b58a4fb8ecfae607d58b
|
|
| MD5 |
b931fa7ce42dff85dc80cf982cccf945
|
|
| BLAKE2b-256 |
ca4bbca3850ea2ff6a10a8a86ce58977268f8f71aa6f069e1a132171f57534f1
|
Provenance
The following attestation bundles were made for django_ninja_search-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on anandrnair547/django-ninja-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_ninja_search-0.2.0-py3-none-any.whl -
Subject digest:
ac5250a1fefb927248da7a8f5a465569eed325fe83f9b58a4fb8ecfae607d58b - Sigstore transparency entry: 2174113141
- Sigstore integration time:
-
Permalink:
anandrnair547/django-ninja-search@e9d89afeb436f5e3bf28cf7d3d316df32fb322ee -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/anandrnair547
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e9d89afeb436f5e3bf28cf7d3d316df32fb322ee -
Trigger Event:
push
-
Statement type: