MCPcopy
hub / github.com/django/django / _get_default

Method _get_default

django/db/models/fields/__init__.py:1066–1085  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1064
1065 @cached_property
1066 def _get_default(self):
1067 if self.has_default():
1068 if callable(self.default):
1069 return self.default
1070 return lambda: self.default
1071
1072 if self.has_db_default():
1073 from django.db.models.expressions import DatabaseDefault
1074
1075 default = DatabaseDefault(self._db_default_expression, output_field=self)
1076
1077 return lambda: default
1078
1079 if (
1080 not self.empty_strings_allowed
1081 or self.null
1082 and not connection.features.interprets_empty_strings_as_nulls
1083 ):
1084 return return_None
1085 return str # return empty string
1086
1087 @cached_property
1088 def _db_default_expression(self):

Callers 1

get_defaultMethod · 0.95

Calls 4

has_defaultMethod · 0.95
has_db_defaultMethod · 0.95
DatabaseDefaultClass · 0.90
callableFunction · 0.85

Tested by

no test coverage detected