EventPluginSignal: Fixed a problem with plugins that live in a top-level package

This commit is contained in:
Raphael Michel
2016-07-28 20:38:41 +02:00
parent eb72c2d549
commit cf898b3c33

View File

@@ -32,12 +32,14 @@ class EventPluginSignal(django.dispatch.Signal):
searchpath = receiver.__module__ searchpath = receiver.__module__
app = None app = None
mod = None mod = None
while "." in searchpath: while True:
try: try:
if apps.is_installed(searchpath): if apps.is_installed(searchpath):
app = apps.get_app_config(searchpath.split(".")[-1]) app = apps.get_app_config(searchpath.split(".")[-1])
except LookupError: except LookupError:
pass pass
if "." not in searchpath:
break
searchpath, mod = searchpath.rsplit(".", 1) searchpath, mod = searchpath.rsplit(".", 1)
# Only fire receivers from active plugins and core modules # Only fire receivers from active plugins and core modules