Open Legend94rz opened 1 year ago
I have used this same approach and it's working for me, just cross verify the below things:
app.py
file and have included it in the ready
function to enable the use of signals.If everything is set up correctly, the print statement should appear in the terminal where your Celery worker is running.
Follow the instructions by @hetvi01
Example:
app_label -> example
your_project.your_application.apps.py
from django.apps import AppConfig
class ExampleConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "example"
verbose_name = "Examples"
def ready(self) -> None:
import example.signals # noqa: F401
I have custom model that contains a
TaskResult
asOneToOneField
:in my view, I do something like:
Then I found the
_on_task_save
is nerver trigger, but the data is written into the db, which could be checked bypython manage.py shell
and then runTaskResult.objects.all()
.I have found a similar issue https://github.com/celery/django-celery-results/issues/41, but it doesn't solve my problem.
Thanks for any help!