django-concurrency is an optimistic lock  implementation for Django.
Supported Django versions: 1.8.x, 1.9.x, 1.10.x., 1.11.x
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
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 home page:||https://github.com/saxix/django-concurrency|