This page is a map. On the left, a Django or Django REST framework name
you know; on the right, where the same idea lives in rind, and the
chapter that explains it. Read it when you think “how do I write
get_queryset here?”.
rind keeps most of Django’s ideas, but moves many decisions from run time
to compile time, and makes explicit what Django does implicitly. The last
section lists the main differences of spirit.
Django rind Chapter
django-admin startprojectrind newStarting a project
manage.py startapprind add domainStarting a project
an app a domain : one crate per layer (<domain>-models, <domain>-api…) Organising an application
INSTALLED_APPS, ROOT_URLCONFapp(): .models(..), .api(..), .with(..)The command line
settings.pyenvironment variables (DATABASE_URL, BIND, …) and Rust code in app() The command line
manage.pyrind (the tool), and the application’s binaryThe command line
a management command Cli::command("name", "about", function)The command line
runserverrind serveThe command line
inspectdbrind inspectStarting from a database
middleware a plugin’s hook (Around) Plugins
a reusable app (django-cors-headers, …) a plugin, .with(..), behind a Cargo feature Plugins
Django rind Chapter
class Book(models.Model)#[derive(Model)] struct BookModels
Meta.db_table#[model(table = "…")] (always given)Models
CharField(max_length=200)String with #[column(max_length = 200)]Models
null=TrueOption<T>Models
default=…#[column(default = "SQL")], or a default in the inputModels , Inputs
ForeignKey(Author, on_delete=…)author_id: i64 with #[fk(Author, on_delete = …)]Models
related_name / book_setreverse = books on the key, or #[reverse(..)] on the target: never implicitModels
ManyToManyField#[m2m(name = …, through = "…", from = "…", to = "…")]Models
Meta.indexes, unique_together, constraints#[index(..)], #[unique(..)], #[check(..)]Models
an abstract model, a mixin a field group (#[with_fields(..)]) or a behaviour Behaviours
a custom manager, objects.published() a scope : impl Book { fn published() -> Query<Book> } Models , Queries
a default manager that filters #[model(scoped)]: no default query at allModels
signals (post_save, …) none: a hook of the resource, a behaviour, or a function called by name Inputs , Behaviours
Django rind Chapter
Book.objects.filter(year__gt=1970)Query::<Book>::new().filter(Book::year().gt(1970))Queries
"author__name"Book::author().name(): a typed pathQueries
Q(a) | Q(b), ~Q(a)a | b, !a on conditionsQueries
F("price")the path itself, Book::price() Queries
.annotate(n=Count("books"))Author::books().count() in a serializer’s #[annotated], or in a queryQueries , Serializers
select_related, prefetch_relatednot needed: nested fields are loaded per page, in one query each Serializers
.distinct() after a filter through a many relationnot needed: such a filter is an EXISTS Queries
select_for_update()a lock on the query Queries
transaction.atomic()db.begin(); every write of a resource is already a transactionQueries , Inputs
makemigrations / migrate / showmigrationsrind make / rind migrate / rind statusMigrations
makemigrations --checkrind check (and the test rind new writes)Migrations
DATABASES, routers, .using()Db, replicas, ctx.database(name)Databases
DRF rind Chapter
ModelViewSet#[derive(Resource)]Resources
a router, urls.py Api::new("domain").resource::<R>()Resources
ModelSerializer (reading)#[derive(Serializer)], the output Serializers
ModelSerializer (writing), validate_<field>, validate#[derive(Input)], the input Inputs
read_only=True / write_only=Truea field only in the output / only in the input Serializers
source="author_id"#[field(name = "author")] author_idSerializers
a nested serializer #[nested(key = …)], #[nested(many, by = …)]Serializers
SerializerMethodField#[computed(loader = …)], called once per pageSerializers
dynamic fields (?fields=) built in: fields, omit, include Serializers
perform_create, perform_update, save()a hook: impl Writes for R Inputs
django-filter’s FilterSet#[derive(FilterSet)]Filters
search_fields#[search(path, mode)]Filters
ordering_fields, Meta.ordering#[ordering(by(..), default(..))]Filters
PageNumberPaginationbuilt in; {parameters, nav, results} Filters
@action(detail=True)#[action(POST)] taking the objectActions
@action(detail=False)#[action(GET)] without the objectActions
query parameters read by hand typed parameters, #[derive(Parameters)] Parameters
authentication classes an Authenticate implementation, or rind-auth Authentication
djangorestframework-simplejwtrind-auth: POST /token, /token/refreshSigning in
request.userctx.user, an IdentityAuthentication
permission_classes#[rule(..)]Permissions
get_queryset filtering on the usera mode : #[mode(.., query = …)] Permissions
has_object_permissionthe mode’s query: an object outside it is a 404 Permissions
drf-spectacularbuilt in: rind openapi OpenAPI
renderers (CSV, xlsx) ?format=csv, ?format=xlsxExports
APIClient in testsapp.router(..) called with tower’s oneshotTutorial, part 6
Django rind Chapter
django.core.mail, anymailthe mail plugin Mail
Celery, django-q the jobs plugin Jobs
FileField, django-storagesFile columns and the storage pluginFiles
ImageField, easy-thumbnailsthe images plugin Images
the cache framework, cache_page the cache plugin, with ETags Cache
LOGGINGtracing, RUST_LOG, RIND_LOG=jsonLogging
django-cors-headers the CORS settings CORS
django-prometheus the metrics plugin Metrics
Some things a Django developer expects do not exist, on purpose or not
yet:
No admin. rind serves APIs only.
No templates, no forms, no sessions. The front end is a separate
client.
No createsuperuser. Write a command of your own: the
tutorial shows one.
No migrating backwards, no squashing. Migrations go forward; a
mistake is fixed by a new migration.
Errors at compile time. A misspelt field, a relation followed the
wrong way, a rule naming an action that does not exist: the compiler
refuses them, where Django would fail at run time, or silently do
nothing.
Nothing implicit. No reverse relation is guessed, no manager
filters behind your back, no signal runs code from far away. What a
write does is in its hook, or in the behaviours listed on the model.
No N+1 by construction. Nested objects and computed values are
loaded for a whole page at a time. A list reads only the columns of the
fields it sends.
Pages that never overlap. Every ordering ends with the primary key.
SQL you can read. Migrations are plain SQL files, and queries are
built from typed paths that turn into predictable SQL.