django-scheduler
django-scheduler copied to clipboard
Event with rule and USE_TZ flag to False
Hi,
in my django app I've created a Calendar with two Event:
- one normal with start and end date
- a event an associated rule (Rule(frequency = "DAILY", name = "Daily"))
Now, my project have USE_TZ = False. When I try to do:
my_calendar.occurrences_after(date=timezone.now()).next()
or
my_calendar.occurrences_after(date=datetime.datetime.utcnow()).next()
or
my_calendar.occurrences_after(date=datetime.datetime.now()).next()
I got this error message:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/venv/myproject/local/lib/python2.7/site-packages/schedule/utils.py", line 43, in occurrences_after
heapq.heappush(occurrences, (next(generator), generator))
File "/opt/venv/myproject/local/lib/python2.7/site-packages/schedule/models/events.py", line 289, in _occurrences_after_generator
if o_end > after:
TypeError: can't compare offset-naive and offset-aware datetimes
Thank you.
Salvo.
What is the configuration for the USE_TZ =
option in your setting.py file?
If is set to false then you would be compaing naive and aware datetimes.
If you set it to True
that may help.