Django : Can't import 'module'. Check that module is correct


Might look like an already answered question, actually here you have the same problem (kind of) i had. My problem is, it’s just a trick, one line, no explanation (and still it’s different but the solution given works, and that’s part of my problem).
Here’s my project structure, simplified:

So here is how I added my app in INSTALLED_APPS:

from django.apps import AppConfig

class CoreConfig(AppConfig):
    name = 'core'

    #compfactu modules

As I read the django 1.11 documentation, and I quote :

New applications should avoid default_app_config. Instead they should require the dotted path to the appropriate AppConfig subclass to be configured explicitly in INSTALLED_APPS.

Well nice, it’s a new application so i should do that : but i’m getting an error. And it’s not a problem of pythonpath, cause i just opened a python shell and I can do from compfactu.core.apps import CoreConfig with no problem (print the sys.path too, everything’s fine).

But I have this error, here’s a full traceback:

Traceback (most recent call last):
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/apps/", line 147, in create
    app_module = import_module(app_name)
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/importlib/", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'core'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/utils/", line 228, in wrapper
    fn(*args, **kwargs)
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/core/management/commands/", line 117, in inner_run
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/utils/", line 251, in raise_last_exception
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/utils/", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/utils/", line 228, in wrapper
    fn(*args, **kwargs)
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/", line 27, in setup
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/apps/", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/home/jbjaillet/Projets/venvcompfactu/lib/python3.5/site-packages/django/apps/", line 151, in create
    app_name, mod_path, cls_name,
django.core.exceptions.ImproperlyConfigured: Cannot import 'core'. Check that '' is correct.

And from there, all files and class have been generated by django ( startapp).
And when I actually do what’s told in the question I linked above, doing like :

    #compfactu modules

it works ! And I don’t get that point ! Reading the doc (part i’ve just quoted), it SHOULD NOT work (noting that I don’t have a default_app_config in my

So, as the question where I found the “trick” but no explanation, I’m here asking why it works this way when it shouldn’t, and why the solution in the official doc doesn’t work?

Thank you in advance for you time.

Asked By: Bestasttung



According to the documentation, is a full python path to the application.

Full Python path to the application, e.g. ‘django.contrib.admin’.

This attribute defines which application the configuration applies to.
It must be set in all AppConfig subclasses.

It must be unique across a Django project.

Try this:

class CoreConfig(AppConfig):
    name = 'compfactu.core'
Answered By: Håken Lid

In your ensure to include the full path off the app:

class CoreConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'compfactu.core'
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.