class AutoFieldMixin
from django.db.models.fields import AutoFieldMixin
Ancestors (MRO)
- builtins.object
- django.db.models.fields.AutoFieldMixin
Attribute | Value | Defined in |
---|---|---|
db_returning |
True |
django.db.models.fields.AutoFieldMixin |
def check(self, **kwargs)
django.db.models.fields.AutoFieldMixin
def check(self, **kwargs):
return [
*super().check(**kwargs),
*self._check_primary_key(),
]
def contribute_to_class(self, cls, name, **kwargs)
django.db.models.fields.AutoFieldMixin
def contribute_to_class(self, cls, name, **kwargs):
if cls._meta.auto_field:
raise ValueError(
"Model %s can't have more than one auto-generated field."
% cls._meta.label
)
super().contribute_to_class(cls, name, **kwargs)
cls._meta.auto_field = self
def deconstruct(self)
django.db.models.fields.AutoFieldMixin
def deconstruct(self):
name, path, args, kwargs = super().deconstruct()
del kwargs["blank"]
kwargs["primary_key"] = True
return name, path, args, kwargs
def formfield(self, **kwargs)
django.db.models.fields.AutoFieldMixin
def formfield(self, **kwargs):
return None
def get_db_prep_value(self, value, connection, prepared=False)
django.db.models.fields.AutoFieldMixin
def get_db_prep_value(self, value, connection, prepared=False):
if not prepared:
value = self.get_prep_value(value)
value = connection.ops.validate_autopk_value(value)
return value
def validate(self, value, model_instance)
django.db.models.fields.AutoFieldMixin
def validate(self, value, model_instance):
pass