根据下文源码 可得出在django的settings中配置 DJANGO_CELERY_BEAT_TZ_AWARE 参数可控制celery时间格式
D:\app\Python\python37\Lib\site-packages\django_celery_beat\schedulers.py
ModelEntry._default_now
def _default_now(self):
# The PyTZ datetime must be localised for the Django-Celery-Beat
# scheduler to work. Keep in mind that timezone arithmatic
# with a localized timezone may be inaccurate.
if getattr(settings, 'DJANGO_CELERY_BEAT_TZ_AWARE', True):
now = self.app.now()
now = now.tzinfo.localize(now.replace(tzinfo=None))
else:
# this ends up getting passed to maybe_make_aware, which expects
# all naive datetime objects to be in utc time.
now = datetime.datetime.utcnow()
return now
查看celery文档
timezone = 'Asia/Shanghai' # 时间取值时区
enable_utc = False # 涉及时区的时候需要该参数
timezone_aware = False # 关闭aware感知
网友评论