class CheckConstraint

from django.db.models.constraints import CheckConstraint


  

Ancestors (MRO)

  1. builtins.object
  2. django.db.models.constraints.BaseConstraint
  3. django.db.models.constraints.CheckConstraint
AttributeValueDefined in
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.CheckConstraint
django.db.models.constraints.CheckConstraint
    def constraint_sql(self, model, schema_editor):
        check = self._get_check_sql(model, schema_editor)
        return schema_editor._check_sql(self.name, check)
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.CheckConstraint
django.db.models.constraints.CheckConstraint
    def create_sql(self, model, schema_editor):
        check = self._get_check_sql(model, schema_editor)
        return schema_editor._create_check_sql(model, self.name, check)
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.CheckConstraint
django.db.models.constraints.CheckConstraint
    def deconstruct(self):
        path, args, kwargs = super().deconstruct()
        kwargs["check"] = self.check
        return path, args, kwargs
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.CheckConstraint
django.db.models.constraints.CheckConstraint
    def remove_sql(self, model, schema_editor):
        return schema_editor._delete_check_sql(model, self.name)
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.CheckConstraint
django.db.models.constraints.CheckConstraint
    def validate(self, model, instance, exclude=None, using=DEFAULT_DB_ALIAS):
        against = instance._get_field_value_map(meta=model._meta, exclude=exclude)
        try:
            if not Q(self.check).check(against, using=using):
                raise ValidationError(
                    self.get_violation_error_message(), code=self.violation_error_code
                )
        except FieldError:
            pass
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.")