summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAlex Morega <alex@grep.ro>2022-08-23 12:55:30 +0300
committerCarlton Gibson <carlton.gibson@noumenal.es>2022-08-23 11:58:53 +0200
commit8a8a00388b065b3a7c43f7b0d887f64c81a367b8 (patch)
treefee8414b1bfafe31595edbbfcefb93e9fbfcebdb /docs
parent85942cf6692f44d11d6d574b2429d201cc1e0aa7 (diff)
[4.1.x] Fixed #33939 -- Used functools.partial() in transaction.on_commit() examples.
Backport of 7e6b537f5b92be152779fc492bb908d27fe7c52a from main
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/db/transactions.txt6
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/topics/db/transactions.txt b/docs/topics/db/transactions.txt
index d87f31af26..b4c3fbba48 100644
--- a/docs/topics/db/transactions.txt
+++ b/docs/topics/db/transactions.txt
@@ -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