Skip to main content

ci

PyPi PyPI License

A field in a model that stores a snapshot of a model object and retrieves it as a read-only model object

Installation

pip install django-snapshot-field

or from git

pip install -e git+https://githib.com/Apkawa/django-snapshot-field.git#egg=django-snapshot-field

Django and python version compatibles

Python
Django
3.8 3.9 3.10 3.11 3.12 3.13
4.2 ✅ ✅ ✅ ✅ ✅ ✅
5.0 ❌ ❌ ✅ ✅ ✅ ✅
5.1 ❌ ❌ ✅ ✅ ✅ ✅
5.2 ❌ ❌ ✅ ✅ ✅ ✅

Usage

from django.db import models
from snapshot_field.fields import SnapshotModelField

class Example(models.Model):
    name = models.CharField(max_length=20)

class ExampleReference(models.Model):
    name = models.CharField(max_length=20)
    ref = models.ForeignKey(Example)


class ExampleSnapshotModel(models.Model):
    snapshot = SnapshotModelField(null=True)
    snapshot_refs = SnapshotModelField(
        ['tests.Example', ['ExampleReference', {'fields': ['name', 'ref'], 'refs': ['ref']}]]
    )


obj = Example.objects.create(name='test_name')
obj_ref = ExampleReference.objects.create(name='refname', ref=obj)

snap = ExampleSnapshotModel.objects.create(snapshot=obj, snapshot_refs=obj_ref)

assert snap.snapshot.name == obj.name
assert snap.snapshot_refs.name == obj_ref.name
assert snap.snapshot_refs.ref.name == obj.name

obj.delete()
obj_ref.delete()
snap.refresh_from_db()

assert snap.snapshot.name == obj.name
assert snap.snapshot_refs.name == obj_ref.name
assert snap.snapshot_refs.ref.name == obj.name

Metadata

Release files for django-snapshot-field 0.1.5

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

Source distribution (sdist)

Source distribution for django-snapshot-field 0.1.5
File Size Uploaded
django_snapshot_field-0.1.5.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-snapshot-field 0.1.5
File Interpreter ABI Platform
django_snapshot_field-0.1.5-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 17.8 kB

Release files / django_snapshot_field-0.1.5.tar.gz

Download URL django_snapshot_field-0.1.5.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
41bbf02f88dd37c09cd1f60eae40071e91ed3e7f944881d4c79d847cb387cd7c
BLAKE2b-256 checksum
How to use checksums
d0e84f8cb81e303e4125bdb0da7e2f75cc3b2eb17c9bd894fe7c59d5efd355cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Release files / django_snapshot_field-0.1.5-py2.py3-none-any.whl

Download URL django_snapshot_field-0.1.5-py2.py3-none-any.whl
Size 8.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f26c6ac099ab67a2eb0447ad3da1a26c982bc0b87682e079ac508decf1f0967a
BLAKE2b-256 checksum
How to use checksums
af3fd88d5527a6cabac3ddb7995a27555111eaa7fa5fd6318d80bfe343fd04ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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