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

job_pause causes AttributeError 'NoneType' object has no attribute 'strftime' #41

Closed
constantinoantunes opened this issue Nov 15, 2018 · 3 comments

Comments

@constantinoantunes
Copy link

Using django-apscheduler==0.2.13:

  • Add a job
  • Pause the job
  • Open /admin/django_apscheduler/djangojob/

The following error is presented:

AttributeError at /admin/django_apscheduler/djangojob/
'NoneType' object has no attribute 'strftime'

It happens in: lib\site-packages\django_apscheduler\admin.py in next_run_time_sec, line 35

This method:

    def next_run_time_sec(self, obj):
        return obj.next_run_time.strftime("%Y-%m-%d %H:%M:%S")
@jcass77
Copy link
Owner

jcass77 commented Nov 15, 2018

The next_run_time_sec implementation is also problematic for a different reason: if timezone support is activated via USE_TZ, then the string output by next_run_time_sec will show UTC time, while the rest of django-admin shows the local time.

The way that django-apscheduler shows timezone-aware datetimes can be quite confusing as a result.

D4VID0x2 added a commit to D4VID0x2/django-apscheduler that referenced this issue Feb 18, 2020
If a job is paused, when django tries to format the next run time, it receives None because it is paused.
This check displays the "(paused)" string in place of the next run time instead of causing AttributeError 'NoneType' object has no attribute 'strftime'
@D4VID0x2
Copy link
Contributor

D4VID0x2 commented Feb 18, 2020

Can confirm that in django-apscheduler==0.3.0 the issue is still there.
Here is a workaround: #68
add this check before the return statement

if obj.next_run_time is None:
    return "(paused)"

jarekwg added a commit that referenced this issue Apr 2, 2020
@jcass77
Copy link
Owner

jcass77 commented Jul 16, 2020

Fixed via #68.

@jcass77 jcass77 closed this as completed Jul 16, 2020
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

No branches or pull requests

3 participants