Django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. Django

I tried to import User model in service.py file in user_app model

from .models import User

Модель User в .models

class User(AbstractUser):
image = models.ImageField(upload_to='profile-image/')
send_massege = models.BooleanField(default=True)

INSTALLED_APPS

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'products.apps.ProductsConfig',
'user_app.apps.UserAppConfig',
'social_django',
'cart',
'django.contrib.sitemaps',

]

i got this error

    File "E:\Python\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "E:\Python\lib\threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "E:\Python\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "E:\Python\lib\site-packages\django\core\management\commands\runserver.py", line 115, in inner_run
    autoreload.raise_last_exception()
  File "E:\Python\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "E:\Python\lib\site-packages\django\core\management\__init__.py", line 381, in execute
    autoreload.check_errors(django.setup)()
  File "E:\Python\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "E:\Python\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "E:\Python\lib\site-packages\django\apps\registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "E:\Python\lib\site-packages\django\apps\config.py", line 211, in create
    mod = import_module(mod_path)
  File "E:\Python\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "E:\PyProjects\prosite\user_app\apps.py", line 3, in <module>
    from .tasks import send_activation_notification
  File "E:\PyProjects\prosite\user_app\tasks.py", line 3, in <module>
    from .service import send_an
  File "E:\PyProjects\prosite\user_app\service.py", line 4, in <module>
    from .models import User
  File "E:\PyProjects\prosite\user_app\models.py", line 1, in <module>
    from django.contrib.auth.models import AbstractUser
  File "E:\Python\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "E:\Python\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
    class AbstractBaseUser(models.Model):
  File "E:\Python\lib\site-packages\django\db\models\base.py", line 108, in __new__
    app_config = apps.get_containing_app_config(module)
  File "E:\Python\lib\site-packages\django\apps\registry.py", line 253, in get_containing_app_config
    self.check_apps_ready()
  File "E:\Python\lib\site-packages\django\apps\registry.py", line 136, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

open prosite/wsgi.py file and add these lines :

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'prosite.settings')

application = get_wsgi_application()
Back to Top