summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAlex Hill <alex@hill.net.au>2016-06-01 00:17:25 +0800
committerTim Graham <timograham@gmail.com>2016-06-02 14:46:44 -0400
commit85d2b80d5e84aa16454a4cac187b91fec2ec4e48 (patch)
tree409850c8c16ec42c796bb4bc196df084a1495b80 /django
parentf91247f59824522ceef67cac0def8253cf491f6a (diff)
[1.10.x] Fixed #26686 -- Fixed crash when registering model signals with abstract senders.
Backport of 08014fe75b4fc379523f340191a02147ec35f7a3 from master
Diffstat (limited to 'django')
-rw-r--r--django/db/models/signals.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/django/db/models/signals.py b/django/db/models/signals.py
index b5254b8dc2..51c3ff0554 100644
--- a/django/db/models/signals.py
+++ b/django/db/models/signals.py
@@ -3,6 +3,7 @@ from functools import partial
from django.db.models.utils import make_model_tuple
from django.dispatch import Signal
+from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
@@ -15,15 +16,15 @@ class ModelSignal(Signal):
of the `app_label.ModelName` form.
"""
def _lazy_method(self, method, apps, receiver, sender, **kwargs):
+ from django.db.models.options import Options
+
# This partial takes a single optional argument named "sender".
partial_method = partial(method, receiver, **kwargs)
- # import models here to avoid a circular import
- from django.db import models
- if isinstance(sender, models.Model) or sender is None:
- # Skip lazy_model_operation to get a return value for disconnect()
+ if isinstance(sender, six.string_types):
+ apps = apps or Options.default_apps
+ apps.lazy_model_operation(partial_method, make_model_tuple(sender))
+ else:
return partial_method(sender)
- apps = apps or models.base.Options.default_apps
- apps.lazy_model_operation(partial_method, make_model_tuple(sender))
def connect(self, receiver, sender=None, weak=True, dispatch_uid=None, apps=None):
self._lazy_method(super(ModelSignal, self).connect, apps, receiver, sender, dispatch_uid=dispatch_uid)