MCPcopy
hub / github.com/django/django / get_prep_value

Method get_prep_value

django/db/models/fields/__init__.py:1701–1719  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

1699 # get_next_by_FOO and get_prev_by_FOO
1700
1701 def get_prep_value(self, value):
1702 value = super().get_prep_value(value)
1703 value = self.to_python(value)
1704 if value is not None and settings.USE_TZ and timezone.is_naive(value):
1705 # For backwards compatibility, interpret naive datetimes in local
1706 # time. This won't work during DST change, but we can't do much
1707 # about it, so we let the exceptions percolate up the call stack.
1708 try:
1709 name = "%s.%s" % (self.model.__name__, self.name)
1710 except AttributeError:
1711 name = "(unbound)"
1712 warnings.warn(
1713 "DateTimeField %s received a naive datetime (%s)"
1714 " while time zone support is active." % (name, value),
1715 RuntimeWarning,
1716 )
1717 default_timezone = timezone.get_default_timezone()
1718 value = timezone.make_aware(value, default_timezone)
1719 return value
1720
1721 def get_db_prep_value(self, value, connection, prepared=False):
1722 # Casts datetimes into the format expected by the backend

Callers 1

get_db_prep_valueMethod · 0.95

Calls 2

to_pythonMethod · 0.95
get_prep_valueMethod · 0.45

Tested by

no test coverage detected