Model/Field CRUD and filtering go through Django's normal query compiler; vector search goes through an explicit helper instead of a queryset method, because Milvus needs an index built and the collection loaded before a vector column is searchable at all — see API below. Relation lookups (filter(related__field=...)), .values().annotate(...) grouping and Exists(... OuterRef(...)) (correlated EXISTS, decorrelated into a semi/anti join) all plan through the DBAPI's relational engine, and a TextField is Milvus's analyzer-enabled full-text input.
Installation
pip install milvusql-django
Quick start
# settings.py
DATABASES = {
"default": {
"ENGINE": "milvusql_django",
"NAME": "/path/to/items.db", # or HOST/PORT/USER/PASSWORD for a real server
}
}
# models.py
from django.db import models
from milvusql_django.fields import VectorField
class Item(models.Model):
embedding = VectorField(dim=768)
category = models.CharField(max_length=64)
# after migrating: build the index and load the collection once
from django.db import connection
from milvusql_django.schema import create_index_and_load
create_index_and_load(
connection, "myapp_item", "embedding",
using="HNSW", metric_type="COSINE",
)
# CRUD/filtering: the normal ORM
Item.objects.filter(category="book").values("id")
# vector search: a raw SQL escape hatch, not a queryset method
with connection.cursor() as cursor:
cursor.execute(
'SELECT id FROM "myapp_item" ORDER BY embedding <=> %s LIMIT 5',
[[0.1] * 768],
)
rows = cursor.fetchall()
API
VectorField
A standard Django Field, not a fake-column shim — round-trips list[float] <-> VECTOR(n):
from milvusql_django.fields import VectorField
class Item(models.Model):
embedding = VectorField(dim=768) # dim is optional; omit for an unconstrained VECTOR
milvusql_django.schema.create_index_and_load()
create_index_and_load(
connection, # a Django database connection
table, # collection/table name
field_name, # the VectorField's column
*,
using="HNSW",
metric_type="COSINE",
**index_params, # e.g. M=16, ef_construction=200
)
The explicit follow-up step CreateModel deliberately doesn't do automatically — index method/metric is a query-shape decision (HNSW vs. IVF, COSINE vs. L2), not something a generic schema migration should guess. Call it once, after defining the model, before querying it.
Schema & migrations
This is a first cut, not full Django migration parity:
| Operation | Support |
|---|---|
CreateModel (scalar fields + one or more VectorFields) |
✅ |
AddField |
✅ against a real Milvus server — Milvus Lite's gRPC server doesn't implement AddCollectionField |
RemoveField, AlterField |
❌ raises loudly — Milvus can't alter or drop a field |
See Schema & Migrations for the full picture.
Development
From the workspace root (requires Python 3.12+, uv, task):
task install
task django:lint
task django:test # integration tests need Docker (testcontainers)
License
MIT
Metadata
Release files for milvusql-django 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| milvusql_django-1.0.0.tar.gz | 17.5 kB | Without provenance | Details for milvusql_django-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| milvusql_django-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for milvusql_django-1.0.0-py3-none-any.whl |
Total release size: 39.9 kB
Release files / milvusql_django-1.0.0.tar.gz
| Download URL | milvusql_django-1.0.0.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98a2c6856a7637142a157f4c12036f641482c2f032a77aff66ada478e295a46e
|
|
BLAKE2b-256 checksum How to use checksums |
fa61a6d523d718ab0b1ada7bdc441f7f4f8fb188b778daff6f5c45038d804dec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / milvusql_django-1.0.0-py3-none-any.whl
| Download URL | milvusql_django-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
946b6f118885b7f9fb365975cf861b4cb24294da9d070dc125ea624decbb850b
|
|
BLAKE2b-256 checksum How to use checksums |
08d2206c8b4bdccf747e6428e1a99eceb5c883eaca27e00f9e7f9c70b257e0d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for milvusql-django 1.0.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.