[Fixed]-( django.core.exceptions.ImproperlyConfigured: Cannot import 'apps.accounts'. Check that 'mysite.apps.accounts.apps.AccountsConfig.name' is correct

1👍

The solution was quite counterintuitive. You have to delete the

class AccountsConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = "accounts"

from apps.py\accounts\apps\mysite. Then run python manage.py makemigrations and 2 new models ‘UserPersona‘ and ‘UserProfile‘ are created. the output in the terminal:

mysite\apps\accounts\migrations\0001_initial.py
    - Create model UserPersona
    - Create model UserProfile
👤Jeremi

34👍

The name in apps.py should be the same (value) that you put in INSTALLED_APPS (in settings.py). That’s the correct one.

from django.apps import AppConfig

class AccountsConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "mysite.apps.accounts"

settings.py code:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mysite.apps.accounts',
]

0👍

The name in AppConfig should be same as the name provided in Installed Apps i.e., it should be "mysite.apps.accounts".

-1👍

To define new app you do not need to add it’s path just
app it’s name like that 'accounts' note that app name is case sensitive

so your installed app became :

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accounts',
]

Leave a comment