Python 2.7 django.core.exceptions.AppRegistryNotReady:尚未加载应用程序

时间:2017-09-20 09:32:58

标签: django django-apps

我是学习Django的新手,我使用的是django-1.11.4。默认情况下我使用的是python 2.7。我已经经历了一些类似的问题,但没有运气。请建议。

这是我的追溯:

Traceback (most recent call last):
  File "C:/Users/skum/PQP_Bridge/qspraw7_data/views.py", line 8, in <module>
    from models import PqpModel
  File "C:\Users\skum\PQP_Bridge\qspraw7_data\models.py", line 14, in <module>
    class PqpModel(DjangoCassandraModel):
  File "C:\Python27\lib\site-packages\django_cassandra_engine\models\__init__.py", line 448, in __new__
    name=name
  File "C:\Python27\lib\site-packages\django_cassandra_engine\models\__init__.py", line 489, in _add_django_meta_and_register_model
    app_config = apps.get_containing_app_config(module)
  File "C:\Python27\lib\site-packages\django\apps\registry.py", line 247, in get_containing_app_config
    self.check_apps_ready()
  File "C:\Python27\lib\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.

这些是我安装的应用程序:

INSTALLED_APPS = [
    'django_cassandra_engine',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'qspraw7_data.apps.Qspraw7DataConfig',
    'chartit',
]

apps.py;

from __future__ import unicode_literals

from django.apps import AppConfig


class Qspraw7DataConfig(AppConfig):
    name = 'qspraw7_data'

1 个答案:

答案 0 :(得分:0)

尝试运行以下命令

import django
django.setup()

如果上述不起作用,请尝试执行以下更改

对于django 1.7及更少版本

import os
from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
application = WSGIHandler()

对于django 1.7 WSGI文件:

import os
from django.core.wsgi import get_wsgi_application

os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
application = get_wsgi_application()

这可以帮到你