def make_naive(value, tz=None):
"""Makes a `datetime` naive, i.e. not aware of timezones.
:param value: `datetime` object to make timezone-aware.
:param tz: `tzinfo` object with the timezone information the given value
needs to be converted to. By default, site's own default timezone will
be used.
"""
if getattr(settings, 'USE_TZ', False) and timezone.is_aware(value):
use_tz = tz if tz is not None else timezone.get_default_timezone()
value = timezone.make_naive(value, timezone=use_tz)
return value
评论列表
文章目录