Gabriel NV Ionescu Gabriel NV Ionescu - 2 months ago 7x
Python Question

Dotted path in Django's INTALLED_APPS fails to import

I have a django project of the canonical form:

├── app1/
├── app2/
├── ...
├── project/

With all the additional folders that have started to add up that are not apps (e.g. docs) it's getting harder to keep it organized, so I have decided to make like so:

├── modules/
│ ├──
│   ├── app1/
│   └── app2/
├── project/

However, I cannot, for the life of me, figure out how to reference the apps in my INSTALLED_APPS. Changing

'app1.apps.App1Config' --> 'modules.app1.apps.App1Config'
'app2.apps.App2Config' --> 'modules.app2.apps.App1Config'

will yield the cryptic traceback on ./ runserver (/path/to/venv/ for brevity)

Traceback (most recent call last):
File "/path/to/venv/lib/python3.5/site-packages/django/utils/", line 226, in wrapper
fn(*args, **kwargs)
File "/path/to/venv/lib/python3.5/site-packages/django/core/management/commands/", line 113, in inner_run
File "/path/to/venv/lib/python3.5/site-packages/django/utils/", line 249, in raise_last_exception
File "/path/to/venv/lib/python3.5/site-packages/django/utils/", line 685, in reraise
raise value.with_traceback(tb)
File "/path/to/venv/lib/python3.5/site-packages/django/utils/", line 226, in wrapper
fn(*args, **kwargs)
File "/path/to/venv/lib/python3.5/site-packages/django/", line 27, in setup
File "/path/to/venv/lib/python3.5/site-packages/django/apps/", line 85, in populate
app_config = AppConfig.create(entry)
File "/path/to/venv/lib/python3.5/site-packages/django/apps/", line 142, in create
app_module = import_module(app_name)
File "/path/to/venv/lib/python3.5/importlib/", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 956, in _find_and_load_unlocked
ImportError: No module named 'app1'

Strangely enough, if I remove them from INSTALLED_APPS, the project will (barely) work. For example, requests are funneled to their respective, views are rendered, etc.

I have tried creating an empty new project with a new clean virtual environment with only Django 1.10 running on Python 3.5 but I cannot figure it out. (yes, I have
wherever neccesary)

What am I missing?


As well as updating INSTALLED_APPS, you need to update your attributes to use the new path. For example:

class App1Config(AppConfig):
    name = 'modules.app1'