anfema_django_utils.db.triggers.DenyFieldUpdateTrigger

class DenyFieldUpdateTrigger(field, name, violation_error_message=None, trigger_error_message=None)

Bases: django.db.models.BaseConstraint

Creates a database trigger to deny any updates to the specified field.

Add it like any other Constraint to Meta.constraints.

Implemented as constraint to get automatic support for (vendor specific) sql in migrations and automatic model validation.

Supports the postgresql and mysql backends.

Methods

constraint_sql(model, schema_editor)

create_sql(model, schema_editor)

rtype:

str

deconstruct()

remove_sql(model, schema_editor)

rtype:

str

validate(model, instance[, exclude, using])

rtype:

None

Attributes

default_trigger_error_message

constraint_sql(model, schema_editor)
create_sql(model, schema_editor)
Return type:

str

deconstruct()
default_trigger_error_message
remove_sql(model, schema_editor)
Return type:

str

validate(model, instance, exclude=None, using=DEFAULT_DB_ALIAS)
Return type:

None