#24889: Multi dotted path ImportError
-------------------------------+-------------------------
Reporter: abstractpaper | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
Severity: Normal | Keywords: ImportError
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------
I have a hierarchy of apps with different nesting levels:
{{{
├── apps
│ ├── accounts
│ ├── core
│ ├── modules
│ │ ├── companies
│ │ └── products
}}}
I'm encountering a weird behavior where importing multi dotted apps is
raising an `ImportError` exception:
{{{
Traceback (most recent call last):
File "./manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "/home/aziz/projects/officeman/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 338, in
execute_from_command_line
utility.execute()
File "/home/aziz/projects/officeman/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/home/aziz/projects/officeman/local/lib/python2.7/site-
packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/aziz/projects/officeman/local/lib/python2.7/site-
packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/aziz/projects/officeman/local/lib/python2.7/site-
packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in
import_module
__import__(name)
File "/home/aziz/projects/officeman/django/apps/accounts/models.py",
line 8, in <module>
from apps.modules.companies.models import Company
ImportError: No module named modules.companies.models
}}}
Running python interpreter, I'm able to import all the different packages
at all levels:
{{{
>>> from apps.modules import companies
>>> companies
<module 'apps.modules.companies' from
'apps/modules/companies/__init__.pyc'>
>>>
>>> from apps import modules
>>> modules
<module 'apps.modules' from 'apps/modules/__init__.pyc'>
>>>
>>> import apps
>>> apps
<module 'apps' from 'apps/__init__.pyc'>
}}}
The only reason I'm suspecting this to be a bug is the fact that python
can import all the packages while Django can't. All apps imported fine in
Django before I nested a group of them under `modules`.
--
Ticket URL: <https://code.djangoproject.com/ticket/24889>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.1d61fba0ef37d4869fe4c0a73302f500%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.