Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Tracking dirty fields on a Django model instance (actively maintained)

Project Description

Tracking dirty fields on a Django model instance. Dirty means that field in-memory and database values are different.

This package is compatible and tested with latest versions of Django (1.8, 1.9, 1.10, 1.11 series).

Full documentation

Install

$ pip install django-dirtyfields

Usage

To use django-dirtyfields, you need to:

  • Inherit from DirtyFieldMixin in the Django model you want to track.
from django.db import models
from dirtyfields import DirtyFieldsMixin

class TestModel(DirtyFieldsMixin, models.Model):
    """A simple test model to test dirty fields mixin with"""
    boolean = models.BooleanField(default=True)
    characters = models.CharField(blank=True, max_length=80)
  • Use one of these 2 functions on a model instance to know if this instance is dirty, and get the dirty fields:

    • is_dirty()
    • get_dirty_fields()

Example

>>> from tests.models import TestModel
>>> tm = TestModel.objects.create(boolean=True,characters="testing")
>>> tm.is_dirty()
False
>>> tm.get_dirty_fields()
{}

>>> tm.boolean = False

>>> tm.is_dirty()
True
>>> tm.get_dirty_fields()
{'boolean': True}

Consult the full documentation for more informations.

Release History

Release History

This version
History Node

1.3

History Node

1.2.1

History Node

1.2

History Node

1.1

History Node

1.0.1

History Node

1.0

History Node

0.9

History Node

0.8.2

History Node

0.8.1

History Node

0.8

History Node

0.7

History Node

0.6.1

History Node

0.6

History Node

0.5

History Node

0.4.1

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-dirtyfields-1.3.tar.gz (5.9 kB) Copy SHA256 Checksum SHA256 Source Aug 23, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting