django-ondelta
A django model mixin that makes it easy to react to field value changes on models. Supports an API similar to the model clean method.
Quick Start
Given that I have the model
- class MyModel(models.Model):
mai_field = models.CharField() other_field = models.BooleanField()
And I want to be notified when mai_field’s value is changed and persisted I would simply need to modify my model to include a ondelta_mai_field method.
from ondelta.models import OnDeltaMixin
- class MyModel(OnDeltaMixin):
mai_field = models.CharField() other_field = models.BooleanField()
- def ondelta_mai_field(self, old_value, new_value):
print(“mai field had the value of {}”.format(old_value)) print(“but after we called save it had the value of {}”.format(new_value))
This is the easiest method to watch a single field for changes, but what if we want to perform an action that has an aggregate view of all of the fields that were changed? OnDeltaMixin provides an ondelta_all method for these cases; it is only called once for each save.
from ondelta.models import OnDeltaMixin
- class MyModel(OnDeltaMixin):
mai_field = models.CharField() other_field = models.BooleanField()
- ondelta_all(self, fields_changed):
- if ‘mai_field’ in fields_changed and ‘other_field’ in fields_changed:
print(“Both fields changed during this save!”)
Unsupported Field Types
Some field types are not supported: ManyToManyField, reverse ManyToManyField, reverse ForeignKey, and reverse OneToOneField relations. If you create an ondelta_field_name method for one of these fields, it will not be called when that field is changed.
Help
I like to help people as much as possible who are using my libraries, the easiest way to get my attention is to tweet @adamhaney or open an issue. As long as I’m able I’ll help with any issues you have.
Metadata
Release files for ondelta 0.6.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 |
|---|---|---|---|---|
| ondelta-0.6.0.tar.gz | 3.6 kB | Without provenance | Details for ondelta-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ondelta-0.6.0.macosx-10.11-intel.tar.gz | Details for ondelta-0.6.0.macosx-10.11-intel.tar.gz |
Total release size: 8.3 kB
Release files / ondelta-0.6.0.tar.gz
| Download URL | ondelta-0.6.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aba5307502afb16c9d0c166cef5aa5a7771b8130b147cd6b927802d0ddcb8c91
|
|
BLAKE2b-256 checksum How to use checksums |
521736603a69e523d351f593b6bdc917ff9a6553ce4b0d3a75e6fc4667a1c39d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / ondelta-0.6.0.macosx-10.11-intel.tar.gz
| Download URL | ondelta-0.6.0.macosx-10.11-intel.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ee0f7ceebaa0e37b0d6a6b12620bd43d8e518b18f5d36d3facb18c714588037
|
|
BLAKE2b-256 checksum How to use checksums |
38bcc6ed04b2e1c84717a9f0a7ed13a2a507a5d04a7d8cc89f789d8f843c0f40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for ondelta 0.6.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.