Skip to content

Commit 06aa441

Browse files
author
David Hughes
committed
Fixed import directive and added to explanation of defer().
1 parent dcca4fa commit 06aa441

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ __*You have to make sure to load this before you use signals.*__
1717
For example, add the the following line to your project's **\_\_init\_\_**.py file:
1818

1919
```python
20-
import django_transaction_signals.transaction
20+
import django_transaction_signals
2121
```
2222

2323
Then, to use the signals, create a function and bind it to the **post_commit** signal:
@@ -43,7 +43,12 @@ def save(self, *args, **kwargs):
4343
```
4444

4545
### Usage of defer() function:
46-
This demonstrates a transactional update of a model object which registers a Celery task to be executed when the transaction commits successfully.
46+
__defer()__ registers a function to be run upon successful completion of the current transaction (if one exists). Calling __defer(func, *args, **kwargs)__ translates to the following:
47+
48+
* If a transaction is active, register a post-commit listener to execute func(*args, **kwargs)
49+
* If no transaction is active, execute func(*args, **kwargs) immediately
50+
51+
This example demonstrates a transactional update of a model object which registers a Celery task to be executed when the transaction commits successfully.
4752

4853
```python
4954
from celery.task import task

0 commit comments

Comments
 (0)