--- id: django-concurrency version: "2.8.1" license: MIT license_treatment: permissive maintenance: active --- # django-concurrency — Optimistic lock implementation for Django. Prevents users from doing concurrent editing License: permissive · Maintenance: active · Downloads: 216.5K/mo ## 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 above — 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 pip install django-concurrency uv add django-concurrency 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_current - Install friction: low - Maintenance: active - Downloads: 216.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django optimistic lock, prevent concurrent edits django, django version field, django record conflict detection, django concurrent editing, django edit conflict, django concurrency control, django, concurrency-control, data-integrity [View on SkillFed](https://skillfed.io/packages/django-concurrency) · [View on PyPI](https://pypi.org/project/django-concurrency/)