Skip to content

Opening a Task in Django admin panel errors with 'NoneType' object has no attribute 'scheduled_task_id' #285

@Avasam

Description

@Avasam

Describe the bug
Opening a Task in Django admin panel errors with 'NoneType' object has no attribute 'scheduled_task_id'. Django Traceback:

Environment:


Request Method: GET
Request URL: http://backend/api/v2/admin/scheduler/task/4/change/

Django Version: 5.0.12
Python Version: 3.12.11
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'rest_framework',
 'zygoat_django',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.twitch',
 'allauth.socialaccount.providers.google',
 'allauth.socialaccount.providers.facebook',
 'widget_tweaks',
 'api',
 'scheduler']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'allauth.account.middleware.AccountMiddleware']



Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
               
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/django/contrib/admin/options.py", line 716, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/django/utils/decorators.py", line 188, in _view_wrapper
    result = _process_exception(request, e)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/django/utils/decorators.py", line 186, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/django/contrib/admin/sites.py", line 240, in inner
    return view(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/scheduler/admin/task_admin.py", line 144, in change_view
    execution_list = get_job_executions_for_task(obj.queue, obj)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/scheduler/admin/task_admin.py", line 25, in get_job_executions_for_task
    list(filter(lambda j: job_execution_of(j, scheduled_task), job_list)), key=lambda j: j.created_at, reverse=True
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/scheduler/admin/task_admin.py", line 25, in <lambda>
    list(filter(lambda j: job_execution_of(j, scheduled_task), job_list)), key=lambda j: j.created_at, reverse=True
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/backend-MATOk_fk-py3.12/lib/python3.12/site-packages/scheduler/admin/task_admin.py", line 18, in job_execution_of
    return job.scheduled_task_id == task.id and job.task_type == task.task_type
           ^^^^^^^^^^^^^^^^^^^^^

Exception Type: AttributeError at /api/v2/admin/scheduler/task/4/change/
Exception Value: 'NoneType' object has no attribute 'scheduled_task_id'

To Reproduce
Steps to reproduce the behavior:

  1. Create a Task as such:
    Image
  2. Click on your task
    Image
  3. See error page
    Image

Expected behavior
Seeing information about the task to edit

Screenshots
(see above)

Desktop (please complete the following information):

  • OS: Docker python:3.12-slim
  • python version: 3.12
  • django version: 5.0.12
  • pyproject dependencies:
dependencies = [
  "django ~=5.0.6",
  "django-allauth[socialaccount] ~=0.62.1",
  "django-anymail ~=10.3",
  "django-cors-headers ~=4.3.1",
  "django-environ ~=0.11.2",
  "django-tasks-scheduler ~=4.0.5",
  "django-widget-tweaks ~=1.5.0",
  "djangorestframework ~=3.15.1",
  "djangorestframework-camel-case ~=1.4.2",
  "gunicorn[gevent] ~=22.0.0",
  "pillow ~=10.4.0",
  "psycogreen ~=1.0.2",
  "psycopg2-binary ~=2.9.9",
  "uvicorn[standard] ~=0.29.0",
  "zygoat-django ~=1.0.1",
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions