From d9effdee1c486556eea7627e5f5b6e23da7f34e9 Mon Sep 17 00:00:00 2001 From: Jozef Knaperek Date: Thu, 20 Oct 2022 15:41:22 +0200 Subject: [PATCH] Preserve chosen "using" DB in ConcurrentTransitionMixin --- django_fsm/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_fsm/__init__.py b/django_fsm/__init__.py index bb07487..340060f 100644 --- a/django_fsm/__init__.py +++ b/django_fsm/__init__.py @@ -530,7 +530,7 @@ def _do_update(self, base_qs, using, pk_val, values, update_fields, forced_updat # INSERT if UPDATE fails. # Thus, we need to make sure we only catch the case when the object *is* in the DB, but with changed state; and # mimic standard _do_update behavior otherwise. Django will pick it up and execute _do_insert. - if not updated and base_qs.filter(pk=pk_val).exists(): + if not updated and base_qs.filter(pk=pk_val).using(using).exists(): raise ConcurrentTransition("Cannot save object! The state has been changed since fetched from the database!") return updated