Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

django-neolith

Deploy Django apps, not Django projects.

CI PyPI version Python versions Django versions License: BSD-3-Clause Code style: Ruff Checked with mypy

Status: alpha (0.1.0a2). The API may change before 0.1.

pip install --pre django-neolith

What it is

Neolith makes the Django app, not the Django project, the unit of deployment. An app can run inside a shared process or on its own as a service, with its models, migrations, admin and tests intact, and without changing its code. Apps talk to each other only through typed contracts, so the same code and the same tests hold in both arrangements. Neolith is defined by a specification that is independent of Django and of Python, and django-neolith is its reference implementation.

Features

What this version does. The changelog has the details.

  • Typed contracts. A contract is a Protocol class with @contract and @action, and an implementation is marked with @implements. Request and reply types are Pydantic models in a portable type system, and every check runs when the module is imported.
  • Typed errors. ContractError carries a kind, a message and a detail. An action can declare its own error kinds with their detail records.
  • Calls cross as JSON, in-process too. Every request, reply and error detail is written and read through its declared type, so an in-process call carries exactly what a remote one will.
  • App declaration. An app declares what it provides, requires and owns on its NeolithAppConfig, and the declaration is checked when the class is defined.
  • Checks before serving. At start-up the host resolves every required contract to a provider and validates each implementation, listing every refusal in one error; once those pass, it runs its system checks on the settings and reports all their errors together.
  • One database per app. neolith.routers.AppRouter keeps each app's data on a database alias of its own.
  • Call context. A principal, a trace, a deadline and the calling app travel with each call. A root is opened for each request by RootMiddleware, and for a command or background work by command_scope. A request's principal comes from the backends listed in NEOLITH["PRINCIPAL_BACKENDS"], such as neolith.principals.DjangoUserBackend for the logged-in Django user.
  • Request principal. Ordered principal backends, such as neolith.principals.DjangoUserBackend, name who a request is for, and PrincipalMiddleware fixes that principal for the request's calls.
  • One app alone. neolith run <app> boots apps from their declarations and serves them, and neolith migrate <app> applies each app's migrations to its own database.

Not yet in this version: the HTTP transport, the conformance suite and events. See the roadmap below.

A short example

A contract, in a contract package other apps may import:

# inventory/contracts.py
from typing import Protocol

from pydantic import BaseModel

from neolith import action, contract


class ReserveRequest(BaseModel):
    sku: str
    qty: int


class ReserveReply(BaseModel):
    reserved: int


@contract("inventory.v1")
class Inventory(Protocol):
    @action(idempotent=True)
    def reserve(self, request: ReserveRequest) -> ReserveReply: ...

Its implementation, private to the app that provides it:

# inventory/services.py
from neolith import CallContext, implements

from inventory.contracts import Inventory, ReserveReply, ReserveRequest


@implements(Inventory)
class InventoryService:
    def reserve(self, request: ReserveRequest, ctx: CallContext) -> ReserveReply:
        return ReserveReply(reserved=request.qty)

The two apps' declarations:

# inventory/apps.py
from neolith import NeolithAppConfig, Provided

from inventory.contracts import Inventory


class InventoryConfig(NeolithAppConfig):
    name = "inventory"
    label = "inventory"
    provides = (
        Provided(
            Inventory,
            implementation="inventory.services.InventoryService",
            principal_from=("shop",),  # apps that may pass a principal on their calls
        ),
    )


# shop/apps.py
from neolith import NeolithAppConfig

from inventory.contracts import Inventory


class ShopConfig(NeolithAppConfig):
    name = "shop"
    label = "shop"
    requires = (Inventory,)

And a call from the shop app, which knows the contract and nothing else of inventory:

# shop/orders.py
from neolith import ContractError, connect

from inventory.contracts import ReserveRequest

inventory = connect("inventory.v1")


def place_order(sku: str, qty: int) -> int:
    try:
        reply = inventory.reserve(ReserveRequest(sku=sku, qty=qty))
    except ContractError as error:
        print(error.kind)  # "unavailable", "conflict", ...
        raise
    return reply.reserved

The settings, beside the project's usual ones such as SECRET_KEY. They end with the host's builder, which builds INSTALLED_APPS, DATABASES and DATABASE_ROUTERS from the apps' declarations and NEOLITH, and checks the rest before the host serves:

# settings.py
from neolith.host import build_settings

MIDDLEWARE = [
    "neolith.middleware.RootMiddleware",  # first, and listed once
    "neolith.middleware.PrincipalMiddleware",  # listed once
]
NEOLITH = {}

globals().update(build_settings(["inventory", "shop"], globals()))

With these, a view in the shop app can call place_order directly; a command opens its root first, with neolith.command_scope("shop"). A test runs every Python block on this page under these settings.

To run apps without a project, put the deployer's names (SECRET_KEY, MIDDLEWARE, ROOT_URLCONF, NEOLITH and the rest) in a module that does not call the builder, then apply the migrations and serve:

$ neolith migrate inventory shop --settings deploy
$ neolith run inventory shop --settings deploy --bind 127.0.0.1:8000

neolith run uses Django's development server, which is not for production; in production, serve a settings module like the one above with any WSGI or ASGI server. On SIGINT or SIGTERM it stops taking requests and gives each request in flight until NEOLITH["REQUEST_DEADLINE"], or 30 seconds when that is None. Under another server, give its graceful shutdown a timeout no shorter than the request deadline. In a host built by a settings module, manage.py migrateapps is the migrate step, and manage.py migrateapps --check reports what the host would refuse at start-up.

Roadmap

The steps to 0.1 are in the roadmap.

Licensed under the BSD 3-Clause License.

Metadata

Release files for django-neolith 0.1.0a2

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

Source distribution (sdist)

Source distribution for django-neolith 0.1.0a2
File Size Uploaded Provenance Actions
django_neolith-0.1.0a2.tar.gz 792.5 kB With provenance Details for django_neolith-0.1.0a2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-neolith 0.1.0a2
File Interpreter ABI Platform Actions
django_neolith-0.1.0a2-py3-none-any.whl Python 3 none any Details for django_neolith-0.1.0a2-py3-none-any.whl

Total release size: 954.2 kB

Release files / django_neolith-0.1.0a2.tar.gz

Download URL django_neolith-0.1.0a2.tar.gz
Size 792.5 kB
Tags Source
SHA-256 checksum
How to use checksums
27bf7b923638bc10bd930b798ef93cdae3059fb637bd37df7b7784cc4f7bcca4
BLAKE2b-256 checksum
How to use checksums
1ff48c081f6b8b9d619affde80b5cadc81c7bf970e6e52c08f191cae92c6e181
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / django_neolith-0.1.0a2-py3-none-any.whl

Download URL django_neolith-0.1.0a2-py3-none-any.whl
Size 161.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fed89199c9db9d96fc39fac54980c67586a436000aa5df1c14a973dc6be97cb9
BLAKE2b-256 checksum
How to use checksums
0301d0383b19a6a9cb4c692f26f154ccfa1708298194d397fbe2d77a45c1bada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for django-neolith 0.1.0a2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_neolith-0.1.0a2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

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.

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