Skip to main content

Ryx for Rust

Ryx is a Django-style ORM for Rust. Async-native, with zero Python dependencies.

use ryx_rs::{model, ObjectsManager};

#[model]
struct Post {
#[field(pk)]
id: i64,
title: String,
views: i64,
active: bool,
}

let posts = ObjectsManager::<Post>::new()
.filter("active", true)
.order_by("-views")
.all().await?;

Many older snippets use a convenience helper named Post::objects(). The macro does not need that helper; the canonical entry point is ObjectsManager::<Post>::new(). If you prefer the shorter style, define it once:

impl Post {
fn objects() -> ObjectsManager<Self> {
ObjectsManager::new()
}
}

Cratesโ€‹

CrateDescription
ryx-rsCore ORM: models, QuerySet, migrations, caching
ryx-macroProc macros: #[model], #[field], #[table], #[relation]

Quick Comparisonโ€‹

FeaturePython (ryx)Rust (ryx-rs)
Model definitionClass + Fields#[model] struct
QuerySetPost.objectsObjectsManager::<Post>::new() or a user-defined Post::objects() helper
Filtering.filter(active=True).filter("active", true)
Q objectsQ(active=True) | Q(...)Q::or(Q::new(...), ...)
Create.create(title="...").create().set("title", "...").save()
MigrationsMigrationRunner([Post])MigrationRunner::new().model::<Post>()
RelationsForeignKey(Author)#[relation(model = "Author", ...)]
CLIpython -m ryx migrateryx migrate
File-based migrations.py files + Autodetector.yaml files + Autodetector
Multi-DB routingMeta.database + model=#[database("alias")]

Next Stepsโ€‹