django-dirtyfields
Tracking dirty fields on a Django model instance.
What it is and what it does
Django Dirty Fields is a mixin that tracks in-memory changes to Django model instances, letting you detect which fields differ from their database values without querying the database. You inherit from DirtyFieldsMixin on any model, then call is_dirty() to check if the instance has unsaved changes or get_dirty_fields() to retrieve a dictionary of changed field names and their original values.
This is useful for conditional logic around saves, audit trails, or avoiding unnecessary database writes. The package has been in production use since its early releases and is tested against a wide range of Django and Python versions. It requires only Django as a dependency and installs as a lightweight pure-Python wheel.
Use it for:
- Check if a model instance has unsaved changes before deciding whether to call save().
- Audit which fields were modified on an instance for logging or change-tracking systems.
- Conditionally trigger side effects only when specific fields change.
- Implement undo/rollback logic by comparing dirty fields to their original database values.
- Validate that certain fields have not been modified before allowing a save operation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Tracks which fields on a Django model instance have been modified in memory but not yet saved to the database, providing methods to check dirty status and retrieve changed field values.
Yes. The package is production-stable, actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a common Django pattern cleanly. Use it when you need to detect in-memory changes to model instances without extra database queries.
Install
django-dirtyfields on PyPI
pip
pip install django-dirtyfieldsuv
uv add django-dirtyfieldspoetry
poetry add django-dirtyfieldsInstalling django-dirtyfields
Before you install
Low friction: pure Python wheel with only Django as a runtime dependency. Actively maintained with recent commits and compatible across Django 3.2 through 6.0 and Python 3.10–3.14.
License in practice
BSD-3-Clause permissive license allows commercial and private use with minimal restrictions beyond attribution and liability disclaimers.
Quickstart
pip install django-dirtyfields
from django.db import models
from dirtyfields import DirtyFieldsMixin
class ExampleModel(DirtyFieldsMixin, models.Model):
boolean = models.BooleanField(default=True)
model = ExampleModel.objects.create(boolean=True)
model.boolean = False
model.is_dirty() # True
model.get_dirty_fields() # {'boolean': True}
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — Django |
| Maintenance | actively maintained — 204 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 670,955/month — #5,406 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_dirtyfields-1.9.9-py3-none-any.whl
Keywords: django, dirtyfields, track, model, changes
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
django-auditlogdjango-auditlog logs changes to Django model…
permissive · top 5,000 on PyPI
django-lifecycleAdds declarative lifecycle hooks to Django…
permissive · top 15,000 on PyPI
django-model-utilsProvides reusable model mixins and field…
permissive · top 5,000 on PyPI
django-perf-recRecords and compares Django database queries…
permissive · top 15,000 on PyPI
django-read-onlyPrevents Django database write operations by…
permissive · top 15,000 on PyPI
django-concurrencyAdds optimistic locking to Django models to…
permissive · top 15,000 on PyPI
django-pghistoryTracks all changes to Django models using…
permissive · top 15,000 on PyPI
django-picklefieldProvides a Django model field that stores and…
permissive · top 5,000 on PyPI
django-fsm-logAutomatically logs state transitions for Django…
permissive · top 15,000 on PyPI
django-reversiondjango-reversion adds version control to Django…
permissive · top 5,000 on PyPI