djanquiltdb-plugin-pghistory
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.12 to 3.15
Django 5.2, 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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djanquiltdb_plugin_pghistory-1.2.0.tar.gz | 63.1 kB | With provenance | Details for djanquiltdb_plugin_pghistory-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djanquiltdb_plugin_pghistory-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for djanquiltdb_plugin_pghistory-1.2.0-py3-none-any.whl |
Total release size: 84.7 kB
Release files / djanquiltdb_plugin_pghistory-1.2.0.tar.gz
| Download URL | djanquiltdb_plugin_pghistory-1.2.0.tar.gz |
|---|---|
| Size | 63.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bc253aad607dcfffa1373f7fb1ed405435e8cc43baa0680b46c307c67f9be4e
|
|
BLAKE2b-256 checksum How to use checksums |
c7d324abc05e8eb8d1623ef2ae2de3bff0a45ddcae88ae0cdcab0c36e71a7c3f
|
| 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 12, 2026.
Transparency logRelease files / djanquiltdb_plugin_pghistory-1.2.0-py3-none-any.whl
| Download URL | djanquiltdb_plugin_pghistory-1.2.0-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff26d3861b91bd255d24f464a6d47edf7151013b733416684825d00304f69904
|
|
BLAKE2b-256 checksum How to use checksums |
7495aca861288355062b32ec467c3a2e684d3f396a5c758e21ed60d955a396ac
|
| 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 12, 2026.
Transparency logSecurity for djanquiltdb-plugin-pghistory 1.2.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for djanquiltdb_plugin_pghistory-1.2.0.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 12, 2026.
Transparency logA 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.