From e515a3c4c83e02570eb83fcc2a0a11318deb80b6 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sat, 27 Apr 2024 12:45:46 +0100 Subject: [PATCH] Clarify delay_on_commit documentation doesn't return the task ID --- docs/django/first-steps-with-django.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/django/first-steps-with-django.rst b/docs/django/first-steps-with-django.rst index 7091e391c01..bc610da0f3c 100644 --- a/docs/django/first-steps-with-django.rst +++ b/docs/django/first-steps-with-django.rst @@ -206,6 +206,11 @@ This API takes care of wrapping the call into the `on_commit`_ hook for you. In rare cases where you want to trigger a task without waiting, the existing :meth:`~celery.app.task.Task.delay` API is still available. +One key difference compared to the ``delay`` method, is that ``delay_on_commit`` +will NOT return the task ID back to the caller. The task is not sent to the broken +when you call the method, only when the Django transaction finishes. If you need the +task ID, best to stick to :meth:`~celery.app.task.Task.delay`. + This task class should be used automatically if you've follow the setup steps above. However, if your app :ref:`uses a custom task base class `, you'll need inherit from :class:`~celery.contrib.django.task.DjangoTask` instead of