class BaseConstraint
from django.db.models.constraints import BaseConstraint
Ancestors (MRO)
- builtins.object
- django.db.models.constraints.BaseConstraint
Attribute | Value | Defined in |
---|---|---|
default_violation_error_message |
Constraint ā%(name)sā is violated. |
django.db.models.constraints.BaseConstraint |
violation_error_code |
None |
django.db.models.constraints.BaseConstraint |
violation_error_message |
None |
django.db.models.constraints.BaseConstraint |
def clone(self)
django.db.models.constraints.BaseConstraint
def clone(self):
_, args, kwargs = self.deconstruct()
return self.__class__(*args, **kwargs)
def constraint_sql(self, model, schema_editor)
django.db.models.constraints.BaseConstraint
def constraint_sql(self, model, schema_editor):
raise NotImplementedError("This method must be implemented by a subclass.")
def contains_expressions(self)
django.db.models.constraints.BaseConstraint
def create_sql(self, model, schema_editor)
django.db.models.constraints.BaseConstraint
def create_sql(self, model, schema_editor):
raise NotImplementedError("This method must be implemented by a subclass.")
def deconstruct(self)
django.db.models.constraints.BaseConstraint
def deconstruct(self):
path = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
path = path.replace("django.db.models.constraints", "django.db.models")
kwargs = {"name": self.name}
if (
self.violation_error_message is not None
and self.violation_error_message != self.default_violation_error_message
):
kwargs["violation_error_message"] = self.violation_error_message
if self.violation_error_code is not None:
kwargs["violation_error_code"] = self.violation_error_code
return (path, (), kwargs)
def get_violation_error_message(self)
django.db.models.constraints.BaseConstraint
def get_violation_error_message(self):
return self.violation_error_message % {"name": self.name}
def remove_sql(self, model, schema_editor)
django.db.models.constraints.BaseConstraint
def remove_sql(self, model, schema_editor):
raise NotImplementedError("This method must be implemented by a subclass.")
def validate(self, model, instance, exclude=None, using='default')
django.db.models.constraints.BaseConstraint
def validate(self, model, instance, exclude=None, using=DEFAULT_DB_ALIAS):
raise NotImplementedError("This method must be implemented by a subclass.")