mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
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.
This commit is contained in:
@@ -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().
|
||||
|
||||
Reference in New Issue
Block a user