Skip to content

Commit add218a

Browse files
milind-shakya-spauvipy
authored andcommitted
Fix AttributeError due to new setting being introduced. (#206)
1 parent 52b4e01 commit add218a

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
@@ -200,7 +200,7 @@ def schedule(self):
200200
day_of_month=self.day_of_month,
201201
month_of_year=self.month_of_year,
202202
)
203-
if settings.DJANGO_CELERY_BEAT_TZ_AWARE:
203+
if getattr(settings, 'DJANGO_CELERY_BEAT_TZ_AWARE', True):
204204
crontab = TzAwareCrontab(
205205
minute=self.minute,
206206
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)