Search code examples
pythondjangodjango-mysql

How do you fix the apps aren't loaded yet error in Django using django-mysql?


Im getting this error when trying to start Django in pycharm. I don't understand as it was running properly yesterday.

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

Here is the full trace back:

Traceback (most recent call last):
  File "/Users/matthew/PycharmProjects/GluIQ/DreamIt/views.py", line 2, in <module>
    from Home.models import QuestionAwner, userProject, Files
  File "/Users/matthew/PycharmProjects/GluIQ/Home/models.py", line 4, in <module>
    from django_mysql.models import JSONField
  File "/Users/matthew/python3venv/gluiq/lib/python3.7/site-packages/django_mysql/models/__init__.py", line 7, in <module>
    from django_mysql.models.base import Model  # noqa
  File "/Users/matthew/python3venv/gluiq/lib/python3.7/site-packages/django_mysql/models/base.py", line 11, in <module>
    class Model(models.Model):
  File "/Users/matthew/python3venv/gluiq/lib/python3.7/site-packages/django/db/models/base.py", line 110, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/Users/matthew/python3venv/gluiq/lib/python3.7/site-packages/django/apps/registry.py", line 247, in get_containing_app_config
    self.check_apps_ready()
  File "/Users/matthew/python3venv/gluiq/lib/python3.7/site-packages/django/apps/registry.py", line 125, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Here are the imports for views.py:

from django.shortcuts import render, redirect
from Home.models import QuestionAwner, userProject, Files
from django.views.generic import View
from DreamIt.forms import ProjectMandateForm, StatementOfNeedForm
from braces.views import LoginRequiredMixin
from django.core.files.storage import FileSystemStorage

Here are the imports for models.py:

from django.db import models
from django.conf import settings
from django.core.urlresolvers import reverse
from django_mysql.models import JSONField

Here are my installed apps:

INSTALLED_APPS = [
    'Home.apps.HomeConfig',
    'DreamIt.apps.DreamitConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_mysql',
]

Heres are what I have installed:

django==1.11.20
PyMySQL==0.9.3
coverage==4.5.2
django-bootstrap3-datetimepicker==2.2.3
django-braces==1.13.0
django-mysql==2.4.1
mysql-connector-python==8.0.15
pip==10.0.1
protobuf==3.6.1
pytz==2018.9
setuptools==39.1.0
six==1.12.0

If anyone can help it would be much appreciated. I'm sure I've done something stupid yesterday and forgotten.


Solution

  • This was me being an idiot, i had not selected for PyCharm to run my app using Django.

    For anyone who does this as well its the dropdown in the top right of PyCharm.