Skip to main content

Ferrum

Ferrum is a Django-inspired framework with a Rust runtime core and a Python developer API.

What Ferrum currently provides

  • Rust-owned HTTP runtime (axum + tokio) bridged to Python via pyo3.
  • Django-style management commands (manage.py, startproject, startapp, makemigrations, migrate, showmigrations).
  • App registry and settings boot flow via FERRUM_SETTINGS_MODULE, including apps.py discovery and ready() hooks.
  • Middleware pipeline from MIDDLEWARE (process_request, process_response, process_exception).
  • ORM foundations:
    • Models and fields (CharField, IntegerField, FloatField, BooleanField, ForeignKey, ManyToManyField)
    • QuerySet operations (get, filter, exclude, all, first, last, latest, earliest, exists, count, aggregate, values, values_list, distinct, slicing, create, update, delete, etc.)
    • Expanded lookups (__icontains, __istartswith, __iendswith, __range, __in, __isnull, comparison lookups)
    • Model lifecycle operations (save(update_fields=...), refresh_from_db(), instance delete())
    • Relation loading and traversal (select_related, prefetch_related, reverse managers, M2M manager add/remove/clear/set)
    • Transactions (atomic)
    • App-scoped table naming and migration tracking
  • Safer SQL execution defaults:
    • raw SQL runs through app table allowlist checks by default
    • explicit high-trust bypass via unsafe_unchecked=True for migration/operator workflows
  • Migration planner features:
    • cross-app dependency graph
    • cycle detection
    • target and fake application (migrate <app> <target> --fake)
    • migration metadata checksums (ferrum_migration_meta) with checksum drift detection
    • deterministic warnings for rename/removal/alter autodiff gaps
  • Backend adapter seams:
    • SQLite runtime backend
    • PostgreSQL runtime backend
    • dual-backend ORM parity tests (SQLite + PostgreSQL, PostgreSQL enabled with env)
  • Installed app governance:
    • ferrum_installed_apps sync
    • startup drift enforcement when removing apps that still have applied migrations

Quickstart (uv + maturin)

# Install Python 3.14t (free-threaded)
uv python install 3.14t

# Create virtual environment
uv venv --python 3.14t .venv
source .venv/bin/activate

# Install ferrum-rs
pip install ferrum-rs

# Or install from source
pip install -e .
pip install maturin
maturin develop

Run tests:

pytest tests/
cargo test

Test coverage:

  • Python: 132 passing tests
  • Rust: passing tests

Run PostgreSQL parity variants by setting:

export FERRUM_TEST_POSTGRES_URL="postgresql://<user>:<pass>@localhost:<port>/<db>"
pytest -q

Free-threaded Python only (no GIL)

Ferrum only supports free-threaded CPython with no GIL:

  • Python version: >=3.14
  • Build type: free-threaded (python3.14t / Py_GIL_DISABLED=1)
  • Runtime mode: gil_enabled=False

Set up with uv:

# Install Python 3.14t
uv python install 3.14t

# Create and activate venv
uv venv --python 3.14t .venv
source .venv/bin/activate

# Install from PyPI
pip install ferrum-rs

# Or install from source
pip install maturin
pip install -e .
maturin develop

Verify runtime mode:

python -c "import ferrum; print(ferrum.runtime_info())"

Expected when no-GIL is active:

  • "free_threaded_build": True
  • "gil_enabled": False
  • "no_gil_active": True

Ferrum will fail fast at import if any of the above conditions are not met. If needed, force no-GIL mode at runtime with:

PYTHON_GIL=0 python example_project/manage.py runserver 8131

Create a new project

Use ferrum-admin (script entrypoint) or call management directly.

ferrum-admin startproject mysite
cd mysite
python manage.py help

Generated structure:

mysite/
├── manage.py
└── mysite/
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    ├── asgi.py
    └── wsgi.py

Create an app

python manage.py startapp books

This creates:

  • books/models.py
  • books/apps.py
  • books/views.py
  • books/urls.py
  • books/migrations/

and appends "books" to INSTALLED_APPS.

Re-running startapp books is idempotent and repairs missing scaffold files.

Migrations workflow

python manage.py makemigrations
python manage.py showmigrations
python manage.py migrate

Targeted and fake migration examples:

python manage.py migrate books 0001_initial --fake
python manage.py migrate books 0002_more

Middleware configuration

In settings.py:

MIDDLEWARE = [
    "myproject.middleware.TraceHeaderMiddleware",
    "myproject.middleware.ValueErrorMiddleware",
]

Supported hooks on middleware classes:

  • process_request(self, request) -> HttpResponse | None
  • process_response(self, request, response) -> HttpResponse
  • process_exception(self, request, exc) -> HttpResponse | None

Run server

Default:

python manage.py runserver
  • Uses PORT from settings when not passed explicitly.
  • You can override with a CLI port: python manage.py runserver 9000.
  • Enable stat autoreload in development: python manage.py runserver --reload.

Model lifecycle helpers

book = Book.objects.create(title="Before", pages=100)
book.title = "After"
book.save(update_fields=["title"])
book.refresh_from_db()
book.delete()

Example project in this repo

Reference implementation is in:

  • example_project/manage.py
  • example_project/example_project/settings.py
  • example_project/example_project/urls.py
  • example_project/demo_app/models.py
  • example_project/demo_app/views.py
  • example_project/demo_app/urls.py

Try:

# From the ferrum-rs source directory
python example_project/manage.py makemigrations demo_app --name initial
python example_project/manage.py migrate
python example_project/manage.py runserver 8131

Then:

curl -i http://127.0.0.1:8131/books/
curl -i -X POST http://127.0.0.1:8131/books/create/
curl -i http://127.0.0.1:8131/books/1
curl -i -X POST http://127.0.0.1:8131/relationships/seed/
curl -i http://127.0.0.1:8131/books/1/graph/
curl -i http://127.0.0.1:8131/books/1/buyers/
curl -i http://127.0.0.1:8131/buyers/1/books/
curl -i http://127.0.0.1:8131/books/queryset/
curl -i -X POST http://127.0.0.1:8131/books/lifecycle-demo/
curl -i http://127.0.0.1:8131/middleware/42/?q=rust
curl -i http://127.0.0.1:8131/middleware/error/

Roadmap

Roadmap and milestone tracking live in:

Metadata

Release files for ferrum-rs 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for ferrum-rs 0.1.1
File Interpreter ABI Platform Actions
ferrum_rs-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for ferrum_rs-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl

Release files / ferrum_rs-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl

Download URL ferrum_rs-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b4e572bd473a0af198af5127d24b868a90f6900fc5bfcfa2350f0f0d2019333b
BLAKE2b-256 checksum
How to use checksums
52982458f4bd68828f74a8fac9a9b42a50ed1aa98f71df11e8cc82c5c107b8d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for ferrum-rs 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page