#24801: AppConfigs aren't loaded when the application is in a nested directory
----------------------------------------+------------------------
               Reporter:  jarshwah      |          Owner:  nobody
                   Type:  Bug           |         Status:  new
              Component:  Core (Other)  |        Version:  master
               Severity:  Normal        |       Keywords:
           Triage Stage:  Unreviewed    |      Has patch:  0
    Needs documentation:  0             |    Needs tests:  0
Patch needs improvement:  0             |  Easy pickings:  0
                  UI/UX:  0             |
----------------------------------------+------------------------
 We had someone in IRC trying to use a custom AppConfig with an application
 that was installed to a subdirectory called "apps". The AppConfig wasn't
 being picked up, and the import_module machinery was throwing errors. I've
 replicated this locally too.

 Application at: project/top/drill/

 {{{

 INSTALLED_APPS = [
     'top.drill',  # with default_app_config
     'top.drill.apps.DrillConfig',  # without default_app_config
 ]

 $ ./manage.py shell
 Traceback (most recent call last):
   File "./manage.py", line 9, in <module>
     execute_from_command_line(sys.argv)
   File "/vagrant/venv/lib/python3.3/site-
 packages/django/core/management/__init__.py", line 427, in
 execute_from_command_line
     utility.execute()
   File "/vagrant/venv/lib/python3.3/site-
 packages/django/core/management/__init__.py", line 391, in execute
     django.setup()
   File "/vagrant/venv/lib/python3.3/site-packages/django/__init__.py",
 line 21, in setup
     apps.populate(settings.INSTALLED_APPS)
   File "/vagrant/venv/lib/python3.3/site-
 packages/django/apps/registry.py", line 85, in populate
     app_config = AppConfig.create(entry)
   File "/vagrant/venv/lib/python3.3/site-packages/django/apps/config.py",
 line 137, in create
     app_module = import_module(app_name)
   File "/vagrant/venv/lib64/python3.3/importlib/__init__.py", line 90, in
 import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
   File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
   File "<frozen importlib._bootstrap>", line 1529, in
 _find_and_load_unlocked
 ImportError: No module named 'drill'
 }}}

 Problem happens using default_app_config or by referencing the AppConfig
 from INSTALLED_APPS. I suspect there's a problem related to importing
 modules when the application isn't in the project root directory.

 I think that https://code.djangoproject.com/ticket/23470 was the same
 problem, but it was never fully investigated.

--
Ticket URL: <https://code.djangoproject.com/ticket/24801>
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/051.6699e8387386edda456c7bf0ce1140eb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to