Skip to main content

Spring Boot-style @injectable autowiring for Python — zero manual wiring, any DI backend.

Project description

django-autowired

Spring Boot-style @injectable autowiring for Python. Any DI backend. Zero manual wiring.

PyPI version Python versions License CI

Why

In large Django / FastAPI / Flask codebases, hand-rolling injector.Module subclasses with binder.bind(IRepository, to=SqlRepository) calls does not scale. It's boilerplate, it's easy to forget, and every new service becomes a coordination problem.

django-autowired brings the Spring Boot ergonomic to Python: decorate a class with @injectable, point an AppConfig (or FastAPI lifespan, or Flask extension) at the packages to scan, and the rest happens at boot.

Features

Zero wiring No Module subclasses, no binder.bind() calls. Just @injectable.
Backend-agnostic Works with injector, lagom, wireup, or dishka. Swap with one line.
Framework-agnostic core Django, FastAPI, Flask, or plain Python — all first-class.
Fail loud at boot Duplicate bindings, missing backends, and unresolvable types raise typed errors.
Test-friendly Pytest fixtures, overrides, and a context manager ship with the library.
Thread-safe registry Concurrent registration is safe by construction.
Introspection python -m django_autowired inspect prints your DI graph as a table, tree, JSON, or Mermaid diagram.

Quickstart (Django)

# myapp/apps.py
from django_autowired.integrations.django import AutowiredAppConfig

class MyAppConfig(AutowiredAppConfig):
    name = "myapp"
    autowired_packages = ["myapp.services", "myapp.adapters"]

# myapp/services.py
from django_autowired import injectable

@injectable()
class GreetingService:
    def greet(self) -> str:
        return "hello"

# myapp/views.py
from django_autowired import container
from myapp.services import GreetingService

def index(request):
    svc = container.get(GreetingService)
    return HttpResponse(svc.greet())

That's it. No modules. No binder. No manual wiring.

Backend support

Backend Status Priority Notes
injector default Most complete. Thread scope supported.
lagom Auto-resolves concretes from type hints.
wireup Thread scope falls back to singleton.
dishka Rebuild-on-override semantics.

Install the backend you want:

pip install "django-autowired[injector]"   # default
pip install "django-autowired[lagom]"
pip install "django-autowired[wireup]"
pip install "django-autowired[dishka]"

Framework support

Framework Status Priority
Django priority
FastAPI
Flask
Plain Python

Installation

pip install django-autowired                       # core only (no backend)
pip install "django-autowired[injector]"           # default backend
pip install "django-autowired[django,injector]"    # Django + injector
pip install "django-autowired[fastapi,injector]"   # FastAPI + injector
pip install "django-autowired[flask,injector]"     # Flask + injector
pip install "django-autowired[dev]"                # everything + test/lint/docs

Or with uv:

uv add "django-autowired[django,injector]"

Documentation

Full docs at tylersuehr7.github.io/django-autowired.

License

MIT © 2026 Tyler R. Suehr

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_autowired-0.4.0.tar.gz (75.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_autowired-0.4.0-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

Details for the file django_autowired-0.4.0.tar.gz.

File metadata

  • Download URL: django_autowired-0.4.0.tar.gz
  • Upload date:
  • Size: 75.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_autowired-0.4.0.tar.gz
Algorithm Hash digest
SHA256 236fb4a5900b5c57c7198a037f3b8d7907b3ed09f6dd1fe52844cdb1228f41de
MD5 1dbac868c12b9be0c2961db6cfa7db4d
BLAKE2b-256 1924014e2ca2c87f8dbf356b6dcf372a5a54b087ec22cddc31f87d6cc6e5916f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_autowired-0.4.0.tar.gz:

Publisher: publish.yml on tylersuehr7/django-autowired

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_autowired-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_autowired-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 570f0128a854ff5ad12ca2462255f50831b6b0981fdddaf0e8f7a927dcc745ac
MD5 3aa560fc72ffab9cbeb0ca69897a2265
BLAKE2b-256 a46fd19a91a2bd4b02200fc0a523b1df6020197813e825c769636c59999bda7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_autowired-0.4.0-py3-none-any.whl:

Publisher: publish.yml on tylersuehr7/django-autowired

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page