Skip to content

Commit

Permalink
Keep dynamically added model receivers at the end when unmuting signals
Browse files Browse the repository at this point in the history
Receiver order is somewhat important and packages like `django-dirtyfields` adds receivers dynamically where it can reset the model state. This change restores the original receivers first then appends the dynamically added receivers.
  • Loading branch information
shosca authored Jun 9, 2022
1 parent 869e1b0 commit 17844ee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion factory/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def __exit__(self, exc_type, exc_value, traceback):
logger.debug('mute_signals: Restoring signal handlers %r',
receivers)

signal.receivers += receivers
signal.receivers = receivers + signal.receivers
with signal.lock:
# Django uses some caching for its signals.
# Since we're bypassing signal.connect and signal.disconnect,
Expand Down

0 comments on commit 17844ee

Please sign in to comment.