如何使用 django-mysql 修复 Django 中的应用程序尚未加载错误?

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

我在 pycharm 中尝试启动 Django 时遇到此错误。我不明白,因为昨天 运行 正确。

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

这是完整的回溯:

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.

以下是 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

以下是 models.py 的导入:

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

这是我安装的应用程序:

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',
]

这是我安装的:

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

如果有人能提供帮助,我们将不胜感激。我敢肯定我昨天做了一些愚蠢的事情而忘记了。

我是个白痴,我没有使用 Django 选择 PyCharm 到 运行 我的应用程序。

对于任何这样做的人,它也是 PyCharm 右上角的下拉菜单。