1
0
mirror of https://github.com/django/django.git synced 2025-04-22 00:04:43 +00:00

[4.1.x] Fixed #33939 -- Used functools.partial() in transaction.on_commit() examples.

Backport of 7e6b537f5b92be152779fc492bb908d27fe7c52a from main
This commit is contained in:
Alex Morega 2022-08-23 12:55:30 +03:00 committed by Carlton Gibson
parent 85942cf669
commit 8a8a00388b

View File

@ -308,9 +308,11 @@ Pass any function (that takes no arguments) to :func:`on_commit`::
transaction.on_commit(do_something)
You can also wrap your function in a lambda::
You can also bind arguments to your function using :func:`functools.partial`::
transaction.on_commit(lambda: some_celery_task.delay('arg1'))
from functools import partial
transaction.on_commit(partial(some_celery_task.delay, 'arg1'))
The function you pass in will be called immediately after a hypothetical
database write made where ``on_commit()`` is called would be successfully