Skip to main content

Django Diffable

example workflow Coverage Status

About

A django abstract model that tracks model fields' values and provide some useful api to know what fields have been changed.

Install

pip install django-diffable

Usage

Inherit from DiffableModel:

from diffable.models import DiffableModel
from django.db import models


class Product(DiffableModel):
    name = models.CharField(max_length=30)

Use as follows:

>>> product = Product(name='Atari')
>>> product.has_changed
False
>>> product.changed_fields
[]
>>> product.name = 'Commodore'
>>> product.has_changed
True
>>> product.changed_fields
['name']
>>> product.diff
{'name': ('Atari', 'Commodore')}
>>> product.get_field_diff('name')
('Atari', 'Commodore')
>>> product.save()
>>> product.has_changed
False
>>> product.name = 'ZX Spectrum'
>>> product.has_changed
True
>>> product.refresh_from_db()
>>> product.has_changed
False
>>> product.name
'Commodore'

License

The Django Wicked Historian package is licensed under the FreeBSD License.

Release files for django-diffable 1.0.0

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-diffable 1.0.0
File Size Uploaded
django-diffable-1.0.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-diffable 1.0.0
File Interpreter ABI Platform
django_diffable-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / django-diffable-1.0.0.tar.gz

Download URL django-diffable-1.0.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a22e7e1e0e489473811d44df1ac64c064d25924baddcf0823a0331a209f49d8c
BLAKE2b-256 checksum
How to use checksums
f5bd1dbf5dc5421075cfbc251abb5f258d611075430722fb1014612d9bb30a90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / django_diffable-1.0.0-py3-none-any.whl

Download URL django_diffable-1.0.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
055775f8e229521889f816bcb52303989db098e8e0276f9157e024292f140a7c
BLAKE2b-256 checksum
How to use checksums
f957ab83e9c4fd6385f3c5afdfdd4c963a53211239ea3c7cf5f58476ecbbd05c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release history Release notifications | RSS feed

This release

1.0.0 This release

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