How-To Guides#

Task-focused guides for working with FastAPI-Restly. New to the framework? Start with Getting Started, then the Tutorial; come back here when you have a concrete task.

Use Restly in an Existing Project

Adopt Restly beside existing FastAPI routes, then wire it into your sessions and models.

Use Restly in an Existing Project
Patterns

The idiomatic answers: nested resources and sub-resources, a different list schema, restoring soft-deleted rows, webhook receivers, login flows, custom actions, tenant scoping.

Patterns
Custom Schemas and Field Types

Define schemas with field aliases, write-only fields, and read-only computed fields.

Custom Schemas and Field Types
Work with Foreign Keys Using IDRef

Reference related objects by ID with automatic resolution and 404 on missing.

Work with Foreign Keys Using IDRef
Filter, Sort, and Paginate Lists

Filter, sort, and paginate list endpoints using URL query parameters.

Filter, Sort, and Paginate Lists
Override CRUD Behavior and Add Custom Endpoints

Override the business methods (create, update, …), the request handlers, or the route shells, and add custom routes alongside generated CRUD.

Override CRUD Behavior and Add Custom Endpoints
Shape Error Responses

The typed fr.exc exceptions to raise from overrides, the 422-vs-400 split, and app-wide error envelopes (problem+json).

Shape Error Responses
Share Behaviour with Base Views

Use Python inheritance to share CRUD overrides, dependencies, URL prefixes, and access control across multiple views.

Share Behaviour with Base Views
Compose Views with Mixins

Layer cross-cutting concerns — tenant scoping, soft delete, audit stamping — through cooperative mixins.

Compose Views with Mixins
Use Type Annotations

Use IDSchema, optional view generics, and typed CRUD methods without fighting the framework.

Use Type Annotations
React Admin Integration

Use AsyncReactAdminView to get a backend that ra-data-simple-rest connects to out of the box.

React Admin Integration
Customize the OpenAPI Schema

Per-view tags and responses, custom-route metadata, replacing a generated route’s documented contract, and x-resource-ref.

Customize the OpenAPI Schema
Test APIs with RestlyTestClient and Fixtures

A copy-paste conftest, savepoint-isolated fixtures, and the full fixture reference.

Test APIs with RestlyTestClient and Fixtures
Deploying

Production engine config, Alembic migrations, and an ASGI checklist.

Deploying