jcass77 / django-apscheduler

APScheduler for Django
MIT License
669 stars 97 forks source link

how to save task result to [Django job executions] #193

Closed shifenhutu closed 3 weeks ago

shifenhutu commented 1 month ago

Describe the bug / feature in my task, i return a data , i hope save the data to django

my hope

when i in my task return a data image

i hope i can see the data in [Django job executions] image

thank you very much

TGoddessana commented 4 weeks ago

Hi.

I would like to hear a more detailed use case.

shifenhutu commented 4 weeks ago

@TGoddessana

i am sorry for my bad english

i haven't already implemented that

i used chrome F12 to make this UI


in https://github.com/celery/django-celery-results , it will save the result to django-db,


# app/tasks.py
from celery import shared_task
import time

@shared_task
def add(x, y):
    time.sleep(2)
    return x + y  #   [django-celery-results] will be save result to django db
# app/views.py
from .tasks import add

def test_celery(request):
    add.delay(3, 5)
    return HttpResponse("Celery works")

# app/urls.py
urlpatterns = [
    re_path(r'^test/$', views.test_celery, name="test_celery")
]

django admin => django-celery-results => task detail

image

thank you very much

shifenhutu commented 3 weeks ago

i find https://github.com/django-q2/django-q2 it can save the result to django db

image

TGoddessana commented 1 week ago

@shifenhutu

Sorry for the delay. I'm glad that you found a nice solution for your project.

As you said, a new migration file is required to add the new fields to the database. This can be a load under a system that already has tons of rows (of course, I believe it's the role of the owner of that Django project to review and apply new migrations, not the role of the maintainer of django-apscheduler 😅).

But I think this feature is quite useful and nice, maybe we can implement it in the project? @jcass77 would love to hear your thoughts 😀