summaryrefslogtreecommitdiff
path: root/tests/transaction_hooks/models.py
diff options
context:
space:
mode:
authorAndreas Pelme <andreas@pelme.se>2015-06-30 18:18:56 +0200
committerTim Graham <timograham@gmail.com>2015-06-30 14:51:00 -0400
commit00a1d4d042a7afd139316982c9b57e87d26a894f (patch)
tree65b4427112045acc25d097413b34faeab882ad88 /tests/transaction_hooks/models.py
parent9f0d67137c98aa296471e1b7f57ae43f5bb17db6 (diff)
Fixed #21803 -- Added support for post-commit callbacks
Made it possible to register and run callbacks after a database transaction is committed with the `transaction.on_commit()` function. This patch is heavily based on Carl Meyers django-transaction-hooks <https://django-transaction-hooks.readthedocs.org/>. Thanks to Aymeric Augustin, Carl Meyer, and Tim Graham for review and feedback.
Diffstat (limited to 'tests/transaction_hooks/models.py')
-rw-r--r--tests/transaction_hooks/models.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/transaction_hooks/models.py b/tests/transaction_hooks/models.py
new file mode 100644
index 0000000000..cd2f22b514
--- /dev/null
+++ b/tests/transaction_hooks/models.py
@@ -0,0 +1,10 @@
+from django.db import models
+from django.utils.encoding import python_2_unicode_compatible
+
+
+@python_2_unicode_compatible
+class Thing(models.Model):
+ num = models.IntegerField()
+
+ def __str__(self):
+ return "Thing %d" % self.num