Skip to content

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

License

Notifications You must be signed in to change notification settings

saxix/django-concurrency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5b5fd0f · Mar 1, 2025
Mar 1, 2025
Sep 9, 2018
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Nov 3, 2015
Sep 28, 2024
Feb 27, 2025
Feb 27, 2025
Jan 26, 2024
Sep 9, 2018
Sep 28, 2024
Jul 15, 2016
Sep 9, 2018
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025

Repository files navigation

Django Concurrency

Pypi coverage Test Docs Django Supported Python versions

django-concurrency is an optimistic lock implementation for Django.

It prevents users from doing concurrent editing in Django both from UI and from a django command.

How it works

from django.db import models
from concurrency.fields import IntegerVersionField

class ConcurrentModel( models.Model ):
    version = IntegerVersionField( )
    name = models.CharField(max_length=100)

Now if you try::

a = ConcurrentModel.objects.get(pk=1)
a.name = '1'

b = ConcurrentModel.objects.get(pk=1)
b.name = '2'

a.save()
b.save()

you will get a RecordModifiedError on b.save()

Similar projects

Other projects that handle concurrent editing are django-optimistic-lock and django-locking anyway concurrency is "a batteries included" optimistic lock management system, here some features not available elsewhere:

  • can be applied to any model; not only your code (ie. django.contrib.auth.Group)
  • handle list-editable ChangeList. (handle #11313 <https://code.djangoproject.com/ticket/11313>_)
  • manage concurrency conflicts in admin's actions
  • can intercept changes performend out of the django app (ie using pgAdmin, phpMyAdmin, Toads) (using TriggerVersionField)
  • can be disabled if needed (see disable_concurrency)
  • ConditionalVersionField to handle complex business rules

Project Links