Skip to content

Commit 36002f0

Browse files
authored
run typesense post save actions on transaction commit (#91)
* run typesense post save actions on transaction commit * update action typesense version * update action typesense version
1 parent 86af86b commit 36002f0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Setup TypeSense
5555
uses: jirevwe/[email protected]
5656
with:
57-
typesense-version: 0.26
57+
typesense-version: 0.26.0
5858
typesense-api-key: sample_key
5959

6060
- name: Run tests

django_typesense/signals.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.db import transaction
12
from django.db.models.signals import m2m_changed, post_save, pre_delete
23
from django.dispatch import receiver
34

@@ -9,7 +10,9 @@ def post_save_typesense_models(sender, instance, **kwargs):
910
if not issubclass(sender, TypesenseModelMixin):
1011
return
1112

12-
sender.get_collection(instance, update_fields=kwargs.get('update_fields', [])).update()
13+
transaction.on_commit(
14+
sender.get_collection(instance, update_fields=kwargs.get('update_fields', [])).update
15+
)
1316

1417

1518
@receiver(pre_delete)

0 commit comments

Comments
 (0)