Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timezone aware comparison. #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mush
Copy link

@mush mush commented Oct 12, 2022

django_cron.FailedRunsNotificationCronJob is throwing the following exception with USE_TZ=True.

  File "/.venv/lib64/python3.8/site-packages/django_cron/management/commands/runcrons.py", line 82, in run_cron_with_cache_check
    manager.run(force)
  File "/.venv/lib64/python3.8/site-packages/django_cron/core.py", line 258, in run
    if self.should_run_now(force):
  File "/.venv/lib64/python3.8/site-packages/django_cron/core.py", line 138, in should_run_now
    self.previously_ran_successful_cron = CronJobLog.objects.filter(
  File "/.venv/lib64/python3.8/site-packages/django/db/models/query.py", line 949, in exclude
    return self._filter_or_exclude(True, args, kwargs)
  File "/.venv/lib64/python3.8/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, args, kwargs)
  File "/.venv/lib64/python3.8/site-packages/django/db/models/query.py", line 966, in _filter_or_exclude_inplace
    self._query.add_q(~Q(*args, **kwargs))
  File "/.venv/lib64/python3.8/site-packages/django/db/models/sql/query.py", line 1416, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
  File "/.venv/lib64/python3.8/site-packages/django/db/models/sql/query.py", line 1435, in _add_q
    child_clause, needed_inner = self.build_filter(
  File "/.venv/lib64/python3.8/site-packages/django/db/models/sql/query.py", line 1370, in build_filter
    condition = self.build_lookup(lookups, col, value)
  File "/.venv/lib64/python3.8/site-packages/django/db/models/sql/query.py", line 1216, in build_lookup
    lookup = lookup_class(lhs, rhs)
  File "/.venv/lib64/python3.8/site-packages/django/db/models/lookups.py", line 25, in __init__
    self.rhs = self.get_prep_lookup()
  File "/.venv/lib64/python3.8/site-packages/django/db/models/lookups.py", line 77, in get_prep_lookup
    return self.lhs.output_field.get_prep_value(self.rhs)
  File "/.venv/lib64/python3.8/site-packages/django/db/models/fields/__init__.py", line 1416, in get_prep_value
    warnings.warn("DateTimeField %s received a naive datetime (%s)"
RuntimeWarning: DateTimeField CronJobLog.start_time received a naive datetime (2022-10-13 11:02:56.495028) while time zone support is active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant