ytsejam
ytsejam

Reputation: 3439

Django 3 installed_app shows ModuleNotFoundError in custom folders

while using customized folders, I am having a trouble using my app correctly in Django 3. My folder levels are:

--manage.py
--mdtour
----settings
-------settings.py
----apps
------core
----templates

In core app my apps.py file is:

from django.apps import AppConfig


class CoreConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'core'

But i cannot use my app in Django 3. In settings file I tried to add the app in two ways:

INSTALLED_APPS = [
    'mdtour.apps.core.apps.CoreConfig.core'
]

The error I get:

`ModuleNotFoundError: No module named 'mdtour.apps.core.apps.CoreConfig'; 'mdtour.apps.core.apps' is not a packa`ge

or

INSTALLED_APPS = [
    'mdtour.apps.core'
]

this time I get:

django.core.exceptions.ImproperlyConfigured: Cannot import 'core'. Check that 'mdtour.apps.core.apps.CoreConfig.name' is correct.

How can I correct this error? Thanks

Upvotes: 0

Views: 64

Answers (1)

AKX
AKX

Reputation: 169338

Either just name the module if you're running Django 3.2 (automatic AppConfig discovery):

INSTALLED_APPS = [
    'mdtour.apps.core'
]

Alternately, name the appconfig class.

INSTALLED_APPS = [
    'mdtour.apps.core.apps.CoreConfig'
]

Upvotes: 1

Related Questions