Fields¶
VersionField¶
IntegerVersionField¶
AutoIncVersionField¶
TriggerVersionField¶
- class concurrency.fields.TriggerVersionField¶
This field use a database trigger to update the version field.
Using this you can control external updates (ie using tools like phpMyAdmin, pgAdmin, SQLDeveloper).
The trigger is automatically created during syncdb()
or you can use the triggers management command.
Changed in version 1.0.
Warning
Before django-concurrency 1.0 two triggers per field were created, if you are upgrading you must manually remove old triggers and recreate them using triggers management command
trigger_name¶
Added in version 1.0.
- TriggerVersionField.trigger_name¶
Starting from 1.0 you can customize the name of the trigger created. Otherwise for each TriggerVersionField will be created two triggers named:
'concurrency_[DBTABLENAME]_[FIELDNAME]'
Warning
Any name will be automatically prefixed with concurrency_
triggers management command¶
Helper command to work with triggers:
list
: list existing triggers for each database
drop
: drop exisitng triggers
create
: create required triggers
example
sax@: (concurrency) django-concurrency [feature/triggers*] $ ./demo/manage.py triggers create
DATABASE TRIGGERS
default concurrency_concurrency_triggerconcurrentmodel_u
ConditionalVersionField¶
Added in version 1.1.
This field allow to configure which fields trigger the version increment so to limit the scope of the concurrency checks.
class User(models.Model):
version = ConditionalVersionField()
username = models.CharField(...)
password = models.PasswordField(...)
class ConcurrencyMeta:
check_fields = ('username',)