Vector search for Django models with graph relations
Project description
Django Graph Search
Production-ready vector search for Django models with automatic relation traversal.
- Search across related models (FK, M2M, reverse relations)
- Pluggable vector stores (ChromaDB, FAISS, Qdrant)
- Delta indexing with configurable cache
- Admin UI and REST API out of the box
Fast Start (5 minutes)
1) Install
pip install django-graph-search[chromadb]
Other backends:
pip install django-graph-search[faiss]
pip install django-graph-search[qdrant]
pip install django-graph-search[all]
2) Add app
INSTALLED_APPS = [
...,
"django_graph_search",
]
3) Configure
GRAPH_SEARCH = {
"MODELS": [
{
"model": "shop.Product",
"fields": ["name", "description", "category__name", "tags__name"],
"follow_relations": True,
"relation_depth": 2,
},
# Or index all concrete fields: "fields": "__all__"
],
"VECTOR_STORE": {
"BACKEND": "django_graph_search.backends.ChromaDBBackend",
"OPTIONS": {
"persist_directory": "vector_db",
"collection_name": "django_search",
},
},
"EMBEDDINGS": {
"default": {
"BACKEND": "django_graph_search.embeddings.SentenceTransformerBackend",
"MODEL_NAME": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
"OPTIONS": {},
},
"fast": {
"BACKEND": "django_graph_search.embeddings.SentenceTransformerBackend",
"MODEL_NAME": "sentence-transformers/all-MiniLM-L6-v2",
"OPTIONS": {},
},
},
"DEFAULT_EMBEDDING": "default",
"DEFAULT_RESULTS_LIMIT": 20,
"DELTA_INDEXING": True,
"CACHE": {
"BACKEND": "file", # file | redis | db
"OPTIONS": {"path": "graph_search_cache"},
"KEY_PREFIX": "dgs",
"TTL": 86400,
},
}
4) Add URLs
urlpatterns = [
...,
path("api/search/", include("django_graph_search.urls")),
]
5) Build index
python manage.py build_search_index
6) Search
GET /api/search/?q=wireless+headphones&models=shop.Product&limit=5
API
GET /api/search/?q=query&models=app.Model,app.OtherModel&limit=10GET /api/search/similar/app.Model/123/?limit=10
Admin UI
After install, open /admin/graph-search/ for full-text semantic search across your models.
CLI Commands
python manage.py build_search_index
python manage.py build_search_index --model shop.Product
python manage.py clear_search_index
python manage.py search_index_status
Python API
from django_graph_search import search, index, get_similar
results = search("red smartphone", models=["shop.Product"], limit=5)
index(product_instance)
similar = get_similar(product_instance, limit=5)
Model config: fields
For each model you can list fields to index (including relations via __, e.g. category__name), or use "fields": "__all__" to index all concrete fields of the model. With follow_relations: true, related objects are still traversed up to relation_depth regardless of fields.
{"model": "shop.Product", "fields": "__all__", "follow_relations": True, "relation_depth": 2}
Delta Indexing Cache
Choose a cache backend to skip unchanged objects during reindexing:
file: local files atCACHE.OPTIONS.pathredis: Django cache backend (useCACHE.OPTIONS.alias)db: Django DatabaseCache (useCACHE.OPTIONS.alias)
Why Django Graph Search
Most search solutions ignore relationships. This package builds rich context by traversing your model graph and makes it searchable with modern embeddings. It is fast, modular, and designed for production Django apps.
Project details
Release history Release notifications | RSS feed
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_graph_search-0.1.1.tar.gz.
File metadata
- Download URL: django_graph_search-0.1.1.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de837279a71886f7909d25747e8adede7e039068aa860a3720a077861d9daa6a
|
|
| MD5 |
8966b64f61c7ac7accf1d3b72138ef28
|
|
| BLAKE2b-256 |
af7fb61fd81fb703d7c295f6b13bc710a6b12469d5a992a5ec05456cb6986536
|
Provenance
The following attestation bundles were made for django_graph_search-0.1.1.tar.gz:
Publisher:
workflows.yaml on svalench/django_graph_search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_graph_search-0.1.1.tar.gz -
Subject digest:
de837279a71886f7909d25747e8adede7e039068aa860a3720a077861d9daa6a - Sigstore transparency entry: 881113835
- Sigstore integration time:
-
Permalink:
svalench/django_graph_search@d73d217b70922419bd36d86846135c7a0dfd2778 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/svalench
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflows.yaml@d73d217b70922419bd36d86846135c7a0dfd2778 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_graph_search-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_graph_search-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da3f9727df18087e895cdb9c015224c85d8f1c269416f30b7df0844e5a2fa65c
|
|
| MD5 |
6375382ed2e2fac15aeaaedd3926b56e
|
|
| BLAKE2b-256 |
a2a1e365f55fecac808e9de57b7b6116debff0de3d406d87f8569493bc124ccd
|
Provenance
The following attestation bundles were made for django_graph_search-0.1.1-py3-none-any.whl:
Publisher:
workflows.yaml on svalench/django_graph_search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_graph_search-0.1.1-py3-none-any.whl -
Subject digest:
da3f9727df18087e895cdb9c015224c85d8f1c269416f30b7df0844e5a2fa65c - Sigstore transparency entry: 881113895
- Sigstore integration time:
-
Permalink:
svalench/django_graph_search@d73d217b70922419bd36d86846135c7a0dfd2778 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/svalench
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflows.yaml@d73d217b70922419bd36d86846135c7a0dfd2778 -
Trigger Event:
workflow_dispatch
-
Statement type: