diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index f5ab40673..f7c7e328b 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -9,7 +9,7 @@ from typing_extensions import Literal, Self from django.core.checks import CheckMessage from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist from django.db.models import Model, TextChoices -from django.db.models.expressions import Col, Combinable +from django.db.models.expressions import Col, Combinable, Func from django.db.models.query_utils import RegisterLookupMixin from django.forms import Widget @@ -59,6 +59,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): db_comment: str | None column: str default: Any + db_default: Any error_messages: _ErrorMessagesToOverride def __set__(self, instance: Any, value: _ST) -> None: ... # class access @@ -126,6 +127,7 @@ class IntegerField(Generic[_I], Field[_I | Combinable, _I]): null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., + db_default: _I | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -153,6 +155,7 @@ class IntegerField(Generic[_I], Field[_I | Combinable, _I]): null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., + db_default: _I | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -185,6 +188,7 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]): null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., + db_default: _I | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -212,6 +216,7 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]): null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., + db_default: _I | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -241,6 +246,7 @@ class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]) null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., + db_default: _I | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -267,6 +273,7 @@ class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]) null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., + db_default: _I | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -296,6 +303,7 @@ class SmallIntegerField(IntegerField[_I]): null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., + db_default: _I | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -323,6 +331,7 @@ class SmallIntegerField(IntegerField[_I]): null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., + db_default: _I | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -352,6 +361,7 @@ class BigIntegerField(IntegerField[_I]): null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., + db_default: _I | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -379,6 +389,7 @@ class BigIntegerField(IntegerField[_I]): null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., + db_default: _I | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -408,6 +419,7 @@ class PositiveBigIntegerField(IntegerField[_I]): null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., + db_default: _I | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -435,6 +447,7 @@ class PositiveBigIntegerField(IntegerField[_I]): null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., + db_default: _I | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -466,6 +479,7 @@ class FloatField(Generic[_F], Field[_F | Combinable, _F]): null: Literal[False] = False, db_index: bool = ..., default: _F | Callable[[], _F] | None = ..., + db_default: _F | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -493,6 +507,7 @@ class FloatField(Generic[_F], Field[_F | Combinable, _F]): null: Literal[True], db_index: bool = ..., default: _F | Callable[[], _F] = ..., + db_default: _F | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -529,6 +544,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]): null: Literal[False] = False, db_index: bool = ..., default: _DEC | Callable[[], _DEC] | None = ..., + db_default: _DEC | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -560,6 +576,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]): null: Literal[True], db_index: bool = ..., default: _DEC | Callable[[], _DEC] = ..., + db_default: _DEC | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -594,6 +611,7 @@ class AutoField(AutoFieldMixin, IntegerField[int], metaclass=AutoFieldMeta): null: bool = ..., db_index: bool = ..., default: int | Callable[[], int] | None = ..., + db_default: int | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -625,6 +643,7 @@ class BigAutoField(AutoFieldMixin, BigIntegerField[int]): null: bool = ..., db_index: bool = ..., default: int | Callable[[], int] | None = ..., + db_default: int | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -656,6 +675,7 @@ class SmallAutoField(AutoFieldMixin, SmallIntegerField[int]): null: bool = ..., db_index: bool = ..., default: int | Callable[[], int] | None = ..., + db_default: int | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -690,6 +710,7 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]): null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., + db_default: _C | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -719,6 +740,7 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]): null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., + db_default: _C | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -750,6 +772,7 @@ class SlugField(CharField[_C]): null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., + db_default: _C | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -779,6 +802,7 @@ class SlugField(CharField[_C]): null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., + db_default: _C | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -810,6 +834,7 @@ class EmailField(CharField[_C]): null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., + db_default: _C | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -838,6 +863,7 @@ class EmailField(CharField[_C]): null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., + db_default: _C | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -868,6 +894,7 @@ class URLField(CharField[_C]): null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., + db_default: _C | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -896,6 +923,7 @@ class URLField(CharField[_C]): null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., + db_default: _C | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -926,6 +954,7 @@ class TextField(Generic[_C], Field[_C | Combinable, _C]): null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., + db_default: _C | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -954,6 +983,7 @@ class TextField(Generic[_C], Field[_C | Combinable, _C]): null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., + db_default: _C | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -986,6 +1016,7 @@ class BooleanField(Generic[_B], Field[_B | Combinable, _B]): null: Literal[False] = False, db_index: bool = ..., default: _B | Callable[[], _B] | None = ..., + db_default: _B | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1014,6 +1045,7 @@ class BooleanField(Generic[_B], Field[_B | Combinable, _B]): null: Literal[True], db_index: bool = ..., default: _B | Callable[[], _B] = ..., + db_default: _B | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1042,6 +1074,7 @@ class IPAddressField(Generic[_C], Field[_C | Combinable, _C]): null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., + db_default: _C | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1069,6 +1102,7 @@ class IPAddressField(Generic[_C], Field[_C | Combinable, _C]): null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., + db_default: _C | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1103,6 +1137,7 @@ class GenericIPAddressField( null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., + db_default: _C | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1132,6 +1167,7 @@ class GenericIPAddressField( null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., + db_default: _C | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1170,6 +1206,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]): null: Literal[False] = False, db_index: bool = ..., default: _DD | Callable[[], _DD] | None = ..., + db_default: _DD | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1201,6 +1238,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]): null: Literal[True], db_index: bool = ..., default: _DD | Callable[[], _DD] = ..., + db_default: _DD | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1239,6 +1277,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]): null: Literal[False] = False, db_index: bool = ..., default: _TM | Callable[[], _TM] | None = ..., + db_default: _TM | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1270,6 +1309,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]): null: Literal[True], db_index: bool = ..., default: _TM | Callable[[], _TM] = ..., + db_default: _TM | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1308,6 +1348,7 @@ class DateTimeField(DateField[_DT]): null: Literal[False] = False, db_index: bool = ..., default: _DT | Callable[[], _DT] | None = ..., + db_default: _DT | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1339,6 +1380,7 @@ class DateTimeField(DateField[_DT]): null: Literal[True], db_index: bool = ..., default: _DT | Callable[[], _DT] = ..., + db_default: _DT | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1372,6 +1414,7 @@ class UUIDField(Generic[_U], Field[str | _U, _U]): null: Literal[False] = False, db_index: bool = ..., default: _U | Callable[[], _U] | None = ..., + db_default: _U | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1399,6 +1442,7 @@ class UUIDField(Generic[_U], Field[str | _U, _U]): null: Literal[True], db_index: bool = ..., default: _U | Callable[[], _U] = ..., + db_default: _U | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1438,6 +1482,7 @@ class FilePathField(Generic[_C], Field[_C, _C]): null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., + db_default: _C | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1470,6 +1515,7 @@ class FilePathField(Generic[_C], Field[_C, _C]): null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., + db_default: _C | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1501,6 +1547,7 @@ class BinaryField(Generic[_BIN], Field[_BIN | bytearray | memoryview, _BIN]): null: Literal[False] = False, db_index: bool = ..., default: _BIN | Callable[[], _BIN] | None = ..., + db_default: _BIN | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1530,6 +1577,7 @@ class BinaryField(Generic[_BIN], Field[_BIN | bytearray | memoryview, _BIN]): null: Literal[True], db_index: bool = ..., default: _BIN | Callable[[], _BIN] = ..., + db_default: _BIN | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1563,6 +1611,7 @@ class DurationField(Generic[_TD], Field[_TD, _TD]): null: Literal[False] = False, db_index: bool = ..., default: _TD | Callable[[], _TD] | None = ..., + db_default: _TD | Func | None = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ..., @@ -1592,6 +1641,7 @@ class DurationField(Generic[_TD], Field[_TD, _TD]): null: Literal[True], db_index: bool = ..., default: _TD | Callable[[], _TD] = ..., + db_default: _TD | Func = ..., editable: bool = ..., auto_created: bool = ..., serialize: bool = ...,