Skip to main content

iil-django-commons

Shared backend services library for Django projects on the iil.pet platform.

Implements ADR-131 — Shared Backend Services for all Django Hub projects.

Installation

# Minimal (logging + health only)
pip install -e packages/iil-django-commons

# With cache support (django-redis)
pip install -e "packages/iil-django-commons[cache]"

# Full
pip install -e "packages/iil-django-commons[all]"

# From GitHub (pinned)
pip install "git+https://github.com/achimdehnert/platform.git@v0.1.0#subdirectory=packages/iil-django-commons"

Setup

# settings.py
INSTALLED_APPS = [
    "iil_commons",
    ...
]

MIDDLEWARE = [
    "iil_commons.logging.middleware.CorrelationIDMiddleware",
    "iil_commons.logging.middleware.RequestLogMiddleware",
    ...
]

IIL_COMMONS = {
    "LOG_FORMAT": "json",        # "json" | "human"
    "LOG_LEVEL": "INFO",
    "CACHE_DEFAULT_TTL": 300,
    "HEALTH_CHECKS": ["db", "redis"],
}
# urls.py
from django.urls import include, path

urlpatterns = [
    path("", include("iil_commons.health.urls")),
    ...
]

Modules (Phase 1)

Logging

# Auto-configured via AppConfig.ready() — no manual call needed.
# Override format per project:
IIL_COMMONS = {"LOG_FORMAT": "json"}  # structured JSON for production

Middlewares add X-Correlation-ID header to every request/response and log method, path, status, duration_ms, user_id per request.

Health Checks

Endpoint Purpose
/livez/ Liveness — always 200 if process is running
/healthz/ Readiness — checks DB, Redis, Celery (configurable)
/readyz/ Alias for /healthz/
IIL_COMMONS = {"HEALTH_CHECKS": ["db", "redis"]}

Cache

from iil_commons.cache import cached_view, cached_method, invalidate_pattern

@cached_view(ttl=300, key_func=lambda r: f"guests:{r.org.pk}")
def guest_list(request): ...

class GuestService:
    @cached_method(ttl=60, key_prefix="guest_service")
    def get_active(self, org_id): ...

# Invalidate on model save
invalidate_pattern(f"iil:view:guests:{org.pk}:*")

invalidate_pattern requires django-redis backend (iter_keys support).

Running Tests

cd packages/iil-django-commons
pip install -e ".[dev]"
pytest

Roadmap

Phase Modules Version
✅ Phase 1 Logging, Health, Cache v0.1.0
✅ Phase 2 Rate Limiting, Security Headers v0.2.0
✅ Phase 3 Email abstraction, Celery BaseTask, Prometheus v0.3.0
Phase 4 Consumer integration, own repo + CI, PyPI publish v0.4.0

Metadata

Release files for iil-django-commons 0.3.0

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

Source distribution (sdist)

Source distribution for iil-django-commons 0.3.0
File Size Uploaded Provenance
iil_django_commons-0.3.0.tar.gz 14.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for iil-django-commons 0.3.0
File Interpreter ABI Platform
iil_django_commons-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.2 kB

Release files / iil_django_commons-0.3.0.tar.gz

Download URL iil_django_commons-0.3.0.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
190ba89959283e01bbf8c697940e46a1142c29576fa6737137856860bdcee619
BLAKE2b-256 checksum
How to use checksums
8f105e73621fad2575b2e92eabb7b54157261ca6accebc888786207f34435288
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / iil_django_commons-0.3.0-py3-none-any.whl

Download URL iil_django_commons-0.3.0-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f18eceb407a11c557534f79152e5996176c5eec79a27d4ff9f9d30447681ebf
BLAKE2b-256 checksum
How to use checksums
6863f444276c09a17cce6150d1d35eb119d123e4d8239486882c95d5666eadb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for iil-django-commons 0.3.0

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.3.0 This release

2 release files 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