diff options
| author | Carl Meyer <carl@oddbird.net> | 2014-01-25 19:37:05 -0700 |
|---|---|---|
| committer | Carl Meyer <carl@oddbird.net> | 2014-01-25 19:37:05 -0700 |
| commit | 966b186981d619d964152ebcda1bd844ec5f6c8c (patch) | |
| tree | 8aae6d9114bb2d57cfda5c301194dfb1741b2c81 /django/apps | |
| parent | ee4b806a851f6f7ad121899ed246dbcd7353ca75 (diff) | |
Fixed #17304 -- Allow single-path and configured-path namespace packages as apps.
Also document the conditions under which a namespace package may or may not be
a Django app, and raise a clearer error message in those cases where it may not
be.
Thanks Aymeric for review and consultation.
Diffstat (limited to 'django/apps')
| -rw-r--r-- | django/apps/base.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/django/apps/base.py b/django/apps/base.py index 2ae40e2454..e25178e25d 100644 --- a/django/apps/base.py +++ b/django/apps/base.py @@ -39,9 +39,18 @@ class AppConfig(object): # egg. Otherwise it's a unicode on Python 2 and a str on Python 3. if not hasattr(self, 'path'): try: - self.path = upath(app_module.__path__[0]) + paths = app_module.__path__ except AttributeError: self.path = None + else: + # Convert paths to list because Python 3.3 _NamespacePath does + # not support indexing. + paths = list(paths) + if len(paths) > 1: + raise ImproperlyConfigured( + "The namespace package app %r has multiple locations, " + "which is not supported: %r" % (app_name, paths)) + self.path = upath(paths[0]) # Module containing models eg. <module 'django.contrib.admin.models' # from 'django/contrib/admin/models.pyc'>. Set by import_models(). |
