Skip to main content
Join the chat at https://gitter.im/romgar/django-dirtyfields Published PyPI version Github Actions Test status Coveralls code coverage status Read the Docs documentation status

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 the following Python & Django versions:

Django

Python

1.11, 2.0, 2.1

3.7

2.2, 3.0, 3.1

3.7, 3.8, 3.9

3.2

3.7, 3.8, 3.9, 3.10

4.0

3.8, 3.9, 3.10

Install

$ pip install django-dirtyfields

Usage

To use django-dirtyfields, you need to:

  • Inherit from DirtyFieldsMixin in the Django model you want to track.

    from django.db import models
    from dirtyfields import DirtyFieldsMixin
    
    class ModelTest(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 ModelTest
>>> tm = ModelTest.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 information.

Release files for django-dirtyfields 1.8.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-dirtyfields 1.8.0
File Size Uploaded
django-dirtyfields-1.8.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-dirtyfields 1.8.0
File Interpreter ABI Platform
django_dirtyfields-1.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.6 kB

Release files / django-dirtyfields-1.8.0.tar.gz

Download URL django-dirtyfields-1.8.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2f9488504d18c70acf19c59045d5514711beaaaf8cc84ded136a79910778d6ba
BLAKE2b-256 checksum
How to use checksums
b695544e799393730dfedfe35cfd1251bc64a505c21dfdb9573867c9100186a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Release files / django_dirtyfields-1.8.0-py3-none-any.whl

Download URL django_dirtyfields-1.8.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84750ad11b6555100c0cd60057a9317c1f078dde3f65d51d0867e11894fb25a2
BLAKE2b-256 checksum
How to use checksums
a5037b388c24280faa558ecebee810c4d1d1020920b9adddb2d1d13571735e9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Release history Release notifications | RSS feed

1.9.9

2 release files

1.9.8

2 release files

1.9.7

2 release files

1.9.6

2 release files

1.9.5

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.2

2 release files

1.8.1

2 release files

This release

1.8.0 This release

2 release files

1.7.0

2 release files

1.6.0

1 release file

1.5.0

1 release file

1.4.1

1 release file

1.4

1 release file

1.3.1

1 release file

1.3

1 release file

1.2.1

1 release file

1.2

1 release file

1.1

1 release file

1.0.1

1 release file

1.0

1 release file

0.9

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8

1 release file

0.7

1 release file

0.6.1

1 release file

0.6

1 release file

0.5

1 release file

0.4.1

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.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