Skip to main content

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

Project description

PyPI package

django-concurrency is an optimistic lock [1] implementation for Django.

Supported Django versions:

  • <=2.1.1 supports 1.11.x, 2.1.x, 2.2.x, 3.x

  • >=2.2 supports 3.x

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

How it works

sample code:

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)

  • 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 details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-concurrency-2.3.tar.gz (59.2 kB view details)

Uploaded Source

File details

Details for the file django-concurrency-2.3.tar.gz.

File metadata

  • Download URL: django-concurrency-2.3.tar.gz
  • Upload date:
  • Size: 59.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.3

File hashes

Hashes for django-concurrency-2.3.tar.gz
Algorithm Hash digest
SHA256 36c5ab4836de6e255285661b3b057a36c58c8c69c81287f4c1b7e7be7c733503
MD5 b0980ed6c287882afda1c4a4f2be81b8
BLAKE2b-256 0a4afa807637c066cf87c8dbc82112da167e99de9e9169a008805b5546051ce2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page