Skip to content

Commit b4b4fa2

Browse files
authored
Fixes #298: Use deactivate_branch to handle new change diffs correctly (#306)
Co-authored-by: tom0010 <[email protected]>
1 parent a344502 commit b4b4fa2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

netbox_branching/signal_receivers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .contextvars import active_branch
2020
from .events import *
2121
from .models import Branch, ChangeDiff
22+
from .utilities import deactivate_branch
2223

2324
__all__ = (
2425
'check_pending_migrations',
@@ -79,8 +80,9 @@ def record_change_diff(instance, **kwargs):
7980
current_data = None
8081
else:
8182
model = instance.changed_object_type.model_class()
82-
obj = model.objects.using(DEFAULT_DB_ALIAS).get(pk=instance.changed_object_id)
83-
current_data = serialize_object(obj, exclude=['created', 'last_updated'])
83+
with deactivate_branch():
84+
obj = model.objects.get(pk=instance.changed_object_id)
85+
current_data = serialize_object(obj, exclude=['created', 'last_updated'])
8486
diff = ChangeDiff(
8587
branch=branch,
8688
object=instance.changed_object,

0 commit comments

Comments
 (0)