pythondjangodjango-4.0

How to solucionate the error to Upgrade project to Django 4.2.3


I have a Django project in the 3.1.2 version. However, I need upgrade it to a new version, to 4.2.3.

I´m having the following message when I upgrade the project. How to solucionate this?

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

In the 3.1.2 version, this works well.

Follow the structure of the folders of the project:

|.quality
  |.. apps   
     |... core
     |... changelog
  |.. quality
      |... init.py 
      |... asgi.py 
      |... settings.py 
      |... urls.py 
      |... wsgi.py 
  |.. static 
  |.. templates 
  |.. venv  

Follow the Installed_apps in the settings.py file

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'bootstrapform',
    'apps.core',
    'apps.changelog',   
]

Thank you very much!


Solution

  • there!

    Make sure to place an __init__.py file within your apps directory

    An example of the folder structure would be:

    apps
    ├── __init__.py
    └── core
        ├── __init__.py
        ├── admin.py
        ├── apps.py
        ├── migrations
        │   └── __init__.py
        ├── models.py
        ├── tests.py
        └── views.py
    
    3 directories, 8 files
    

    Additionally, configure your apps/core/apps.py file as follows:

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