Skip to main content

Writable Django models layered over read-only, shared source tables — one view, no coalescing at read time.

Project description

django-overlay

A writable Django model layered on top of a read-only table you don't own — one model to query, no COALESCE/FULL OUTER JOIN at read time.

The problem

You have a big shared read-only table (a vendor import, a third-party dataset) and a small table of tenant edits on top of it. You want one Django model to query, writes landing only in your own table, an edit that copies the row over on first touch, and a foreign key that can still point at it even though Postgres can't put a real FK on a view.

This is OverlayFS applied to Postgres: a writable "upper" table merged with one read-only "lower" table into one "merged" view. Each overlay model has exactly one source table, though which physical table that is can be resolved per tenant — a single, tenant-scoped source, not a union of several.

from django.db import models

from django_overlay.models import OverlayMeta, OverlayModel
from django_overlay.sources import SourceTable


class Person(OverlayModel):
    first_name = models.CharField(max_length=100)

    class OverlayMeta(OverlayMeta):
        @staticmethod
        def get_source():
            return SourceTable(schema="external_source", table="people")


Person.objects.create(first_name="Jane")  # goes straight into the writable table

See docs/INDEX.md for everything else — usage, how it works, ids, uniqueness, deletion, migrations, and running the tests.

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_overlay-0.1.0.tar.gz (107.5 kB view details)

Uploaded Source

Built Distribution

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

django_overlay-0.1.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file django_overlay-0.1.0.tar.gz.

File metadata

  • Download URL: django_overlay-0.1.0.tar.gz
  • Upload date:
  • Size: 107.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for django_overlay-0.1.0.tar.gz
Algorithm Hash digest
SHA256 498da789935aea3c5cb9525dafb67fb3c06a6c539c27b9424eb4031635b76c75
MD5 9c8391799eda43ff4e3850ddc3304154
BLAKE2b-256 5267244e7192993cf62071de22d7249bcf4240f2353faa801c2f6ff0c90c9586

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_overlay-0.1.0.tar.gz:

Publisher: publish.yml on isik-kaplan/django-overlay

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_overlay-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_overlay-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for django_overlay-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43d8debbb180fe7a7ecab297b1bd6fd392df45a82120c58f9c339faa286a2ab7
MD5 ddae5e811339f84ee7ac3be9508951f0
BLAKE2b-256 6c1435ae91a5b8271c01e75921bcdf70e0a6a403b3b81793957ae2178e63be05

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_overlay-0.1.0-py3-none-any.whl:

Publisher: publish.yml on isik-kaplan/django-overlay

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