Skip to main content
DjanQuiltDB

djanquiltdb-plugin-pghistory

PyPI Supported Python versions Supported Django versions Supported PostgreSQL versions CI Documentation BSD-3-Clause licence

django-pghistory records model changes in event tables through Postgres triggers. DjanQuiltDB shards a database across schemas and nodes. This library makes the two work together: its track() works like pghistory.track(), and places each generated event model in the same place as the tracked model, so the history of a sharded model stays inside its shard:

# example/models.py
from djanquiltdb.decorators import pghistory, sharded_model


@pghistory.track(exclude=['password'])
@sharded_model()
class User(models.Model):
    ...

The sharding mode is read from the tracked model, so the mode decorator goes below @track(). For a model that cannot have the decorator, such as a third-party model, set its mode in QUILT_DB['OVERRIDE_SHARDING_MODE'], or use track_sharded, track_mirrored or track_public, which do not read the mode from the model.

The tracking functions can also be imported by name, as in from djanquiltdb.decorators.pghistory import track. The event bases and the queryset are in djanquiltdb.models.pghistory.

Install it through DjanQuiltDB’s extra:

pip install djanquiltdb[pghistory]

The installation guide describes each step in full. pghistory and the pgtrigger app that it builds on go in INSTALLED_APPS. Record the context denormalized, so that each event row keeps its context next to it, and make the pghistory app public:

# settings.py
import pghistory

from djanquiltdb import ShardingMode

INSTALLED_APPS = [
    ...
    'djanquiltdb',
    'pgtrigger',
    'pghistory',
    ...
]

PGHISTORY_CONTEXT_FIELD = pghistory.ContextJSONField()

QUILT_DB = {
    ...
    'OVERRIDE_SHARDING_MODE': {
        ...
        ('pghistory',): ShardingMode.PUBLIC,
    },
}

The triggers reach the template schema and every shard only through migrations, so do not use the pgtrigger management commands that change the database directly.

Full documentation is at https://djanquiltdb.readthedocs.io/en/latest/plugins/pghistory/index.html.

Development

This package is developed in the DjanQuiltDB repository beside djanquiltdb itself. Tests run through tox against the Postgres containers in the repository’s docker-compose.yml; see DOCKER.md at the repository root:

docker compose run --rm test tox

Requirements

  • Python 3.14

  • Django 6.0 or 6.1

  • PostgreSQL 17 or 18

  • djanquiltdb 4.6.0 or newer 4.x

  • django-pghistory 3.9.2 or newer 3.x

Metadata

Release files for djanquiltdb-plugin-pghistory 1.1.1

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

Source distribution (sdist)

Source distribution for djanquiltdb-plugin-pghistory 1.1.1
File Size Uploaded Provenance Actions
djanquiltdb_plugin_pghistory-1.1.1.tar.gz 62.8 kB With provenance Details for djanquiltdb_plugin_pghistory-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for djanquiltdb-plugin-pghistory 1.1.1
File Interpreter ABI Platform Actions
djanquiltdb_plugin_pghistory-1.1.1-py3-none-any.whl Python 3 none any Details for djanquiltdb_plugin_pghistory-1.1.1-py3-none-any.whl

Total release size: 84.3 kB

Release files / djanquiltdb_plugin_pghistory-1.1.1.tar.gz

Download URL djanquiltdb_plugin_pghistory-1.1.1.tar.gz
Size 62.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dd4d100e2b32f913e486af333a106e5dd3b71464b566e1cafcff178f2d8b2557
BLAKE2b-256 checksum
How to use checksums
89db142cb2b179547b6b13e6ed4e62ed6a4c86d0abf535a8f7d639a4b37c1b51
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 3, 2026.

Transparency log

Release files / djanquiltdb_plugin_pghistory-1.1.1-py3-none-any.whl

Download URL djanquiltdb_plugin_pghistory-1.1.1-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7abc50b64890f6bd6cd18cd5c99949eb1c1f396f7635f80c10257882cc6f3bd
BLAKE2b-256 checksum
How to use checksums
f6dd0e97ca61a882ff522cbb5d1822d589f14936123789aad4d511b4cac6f624
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 3, 2026.

Transparency log

Security for djanquiltdb-plugin-pghistory 1.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.

Full provenance

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

Select from 2 files

Attestation for djanquiltdb_plugin_pghistory-1.1.1.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 3, 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