skillfed

django-concurrency

Optimistic lock implementation for Django. Prevents users from doing concurrent editing

django-concurrency v2.8.1 216.5K downloads/30d#9,375 on PyPI466
Permissive license MIT Active released

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-concurrency

uv

uv add django-concurrency

poetry

poetry add django-concurrency

Installing 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

Environment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13

Tags

django optimistic lockprevent concurrent edits djangodjango version fielddjango record conflict detectiondjango concurrent editingdjango edit conflictdjango concurrency control
djangoconcurrency-controldata-integrity

More Dynamic Content packages