Skip to content

Commit 58e0292

Browse files
Merge branch 'master' of github.com:celery/django-celery-beat
2 parents 1ec49cb + add218a commit 58e0292

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

django_celery_beat/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def schedule(self):
218218
day_of_month=self.day_of_month,
219219
month_of_year=self.month_of_year,
220220
)
221-
if settings.DJANGO_CELERY_BEAT_TZ_AWARE:
221+
if getattr(settings, 'DJANGO_CELERY_BEAT_TZ_AWARE', True):
222222
crontab = TzAwareCrontab(
223223
minute=self.minute,
224224
hour=self.hour,

django_celery_beat/schedulers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __init__(self, model, app=None):
9494

9595
last_run_at = model.last_run_at
9696

97-
if settings.DJANGO_CELERY_BEAT_TZ_AWARE:
97+
if getattr(settings, 'DJANGO_CELERY_BEAT_TZ_AWARE', True):
9898
last_run_at = make_aware(last_run_at)
9999

100100
self.last_run_at = last_run_at
@@ -133,7 +133,7 @@ def _default_now(self):
133133
# The PyTZ datetime must be localised for the Django-Celery-Beat
134134
# scheduler to work. Keep in mind that timezone arithmatic
135135
# with a localized timezone may be inaccurate.
136-
if settings.DJANGO_CELERY_BEAT_TZ_AWARE:
136+
if getattr(settings, 'DJANGO_CELERY_BEAT_TZ_AWARE', True):
137137
now = now.tzinfo.localize(now.replace(tzinfo=None))
138138
return now
139139

@@ -151,7 +151,7 @@ def save(self):
151151
for field in self.save_fields:
152152
setattr(obj, field, getattr(self.model, field))
153153

154-
if not settings.DJANGO_CELERY_BEAT_TZ_AWARE:
154+
if not getattr(settings, 'DJANGO_CELERY_BEAT_TZ_AWARE', True):
155155
obj.last_run_at = datetime.datetime.now()
156156

157157
obj.save()

0 commit comments

Comments
 (0)