Browse Source

autodiscover: Adds support for Django 1.7 class names in INSTALLED_APPS. Closes #2248

Ask Solem 10 years ago
parent
commit
4294293600
2 changed files with 9 additions and 0 deletions
  1. 7 0
      celery/loaders/base.py
  2. 2 0
      examples/django/proj/settings.py

+ 7 - 0
celery/loaders/base.py

@@ -278,6 +278,13 @@ def find_related_module(package, related_name):
     """Given a package name and a module name, tries to find that
     module."""
 
+    # Django 1.7 allows for speciying a class name in INSTALLED_APPS.
+    # (Issue #2248).
+    try:
+        importlib.import_module(package)
+    except ImportError:
+        package, _, _ = package.rpartition('.')
+
     try:
         pkg_path = importlib.import_module(package).__path__
     except AttributeError:

+ 2 - 0
examples/django/proj/settings.py

@@ -131,6 +131,8 @@ INSTALLED_APPS = (
     'django.contrib.sites',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+    'django.contrib.admin',
+    'kombu.transport.django.KombuAppConfig',
     'demoapp',
     # Uncomment the next line to enable the admin:
     # 'django.contrib.admin',