django-concurrency
Optimistic lock implementation for Django. Prevents users from doing concurrent editing
What it is and what it does
django-concurrency implements optimistic locking for Django models by adding a version field that increments on each save. When two users fetch the same record and both try to save changes, the second save fails with a RecordModifiedError, alerting the application that a conflict occurred. This prevents silent data loss in concurrent editing scenarios.
The package works by intercepting model saves and comparing the current version field value against what was fetched from the database. It can be applied to any Django model, including those from third-party packages like django.contrib.auth. It handles Django admin list-editable changeists, admin actions, and can even detect changes made outside Django (via database tools) using a TriggerVersionField variant. No runtime dependencies are required beyond Django itself.
Use it for:
- Prevent data loss when multiple users edit the same Django model instance simultaneously in a web application.
- Detect and handle concurrent modifications in Django admin changeists with list-editable fields.
- Intercept concurrent changes made outside the Django application (e.g., direct database edits via pgAdmin or phpMyAdmin).
- Manage concurrency conflicts in Django admin bulk actions on multiple records.
- Implement custom conflict handling logic using ConditionalVersionField for complex business rules.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds optimistic locking to Django models to prevent concurrent editing conflicts, raising an error when multiple users try to save conflicting changes to the same record.
Yes. django-concurrency is actively maintained, has no external dependencies, supports current Django and Python versions, carries an MIT license, and solves a real problem in multi-user Django applications. Install it if your application allows concurrent editing and you need to detect and handle conflicts rather than silently overwriting data.
Install
django-concurrency on PyPI
pip
pip install django-concurrencyuv
uv add django-concurrencypoetry
poetry add django-concurrencyInstalling django-concurrency
Before you install
Low install friction with no runtime dependencies. Actively maintained with recent commits and support for current Django versions (4.2, 5.2, 6.0) and Python 3.10–3.13.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial Django projects.
Quickstart
pip install django-concurrency
from concurrency.fields import IntegerVersionField
from django.db import models
class MyModel(models.Model):
version = IntegerVersionField()
name = models.CharField(max_length=100)
# Now concurrent saves raise RecordModifiedError
Requires Django 4.2 or later and Python 3.10 or later.
Verify before relying
- Whether the package works with all listed Django versions (4.2, 5.2, 6.0) without known issues or edge cases.
- Performance impact of version field checks on models with high write concurrency.
- Whether TriggerVersionField requires specific database support or configuration beyond standard Django setup.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 128 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 216,547/month — #9,375 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_concurrency-2.8.1-py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
django-pglockProvides Postgres advisory locks, table locks,…
permissive · top 5,000 on PyPI
eventsourcingEventsourcing is a Python library for…
permissive · top 15,000 on PyPI
oslo.concurrencyoslo.concurrency provides locking mechanisms…
permissive · top 15,000 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
django-dirtyfieldsTracks which fields on a Django model instance…
permissive · top 15,000 on PyPI
pykkaPykka is a Python implementation of the actor…
permissive · top 15,000 on PyPI
drf-writable-nestedExtends Django REST Framework serializers to…
permissive · top 15,000 on PyPI
django-add-default-valueProvides a Django migration operation to set…
permissive · top 15,000 on PyPI
django-pglocksProvides PostgreSQL advisory locks for Django…
permissive · top 15,000 on PyPI
django-ordered-modelAdds ordering and reordering capabilities to…
permissive · top 15,000 on PyPI