Dataclasses¶
These dataclasses are the in-memory representation of a snapshot. They are
serialised to and deserialised from manifest.json via
to_storage() and
from_storage().
Snapshot¶
- class django_snapshots.Snapshot(version: str, name: str, created_at: datetime, django_version: str, python_version: str, hostname: str, encrypted: bool, pip: list[str], metadata: dict[str, Any], artifacts: list[ArtifactRecord])[source]¶
Bases:
ConfigBaseIn-memory representation of a snapshot manifest.
- __init__(version: str, name: str, created_at: datetime, django_version: str, python_version: str, hostname: str, encrypted: bool, pip: list[str], metadata: dict[str, Any], artifacts: list[ArtifactRecord]) None¶
- artifacts: list[ArtifactRecord]¶
- classmethod from_storage(storage: SnapshotStorage, name: str, snapshot_format: SnapshotFormat = SnapshotFormat.DIRECTORY) Snapshot[source]¶
Read and parse manifest.json from storage for the named snapshot.
- to_storage(storage: SnapshotStorage, snapshot_format: SnapshotFormat = SnapshotFormat.DIRECTORY) None[source]¶
Serialise and write manifest.json to storage.
ArtifactRecord¶
- class django_snapshots.ArtifactRecord(type: str, filename: str, size: int, checksum: str, created_at: datetime, metadata: dict[str, ~typing.Any]=<factory>)[source]¶
Bases:
ConfigBaseImmutable record of a generated artifact as stored in the manifest.
Manifest format¶
A snapshot is stored as a directory (or archive) containing a manifest.json
file and one file per artifact. The manifest is never encrypted even when
encryption is enabled for artifacts, so it can always be read to determine what
a snapshot contains.
{
"version": "1",
"name": "2026-03-13_12-00-00-UTC",
"created_at": "2026-03-13T12:00:00+00:00",
"django_version": "5.2.0",
"python_version": "3.12.0",
"hostname": "prod-web-01",
"encrypted": false,
"pip": ["Django==5.2.0", "django-typer==3.6.4"],
"metadata": {"env": "production"},
"artifacts": [
{
"type": "database",
"filename": "default.sql.gz",
"size": 1234567,
"checksum": "sha256:abc123...",
"created_at": "2026-03-13T12:00:01+00:00",
"metadata": {"database": "default", "connector": "PostgresConnector"}
}
]
}
Version history¶
"1"Initial format, introduced in django-snapshots v0.1.