Django问题:django.core.exceptions.AppRegistryNotReady:尚未加载应用程序

时间:2017-03-10 06:58:00

标签: python django

我是Django的新手。我创建了一个类:

from django.db import models
from cqlengine import columns

class Rsvpstream(models.Model):
    venue_name = columns.Text()
    venue_lon = columns.Decimal(required=False)
    venue_lat = columns.Decimal(required=False)
    venue_id = columns.Integer()
    visibility = columns.Text()
    response = columns.Text()
    guests = columns.Integer()
    member_id = columns.Integer()
    member_name = columns.Text()
    rsvp_id = columns.Integer(primary_key=True)
    rsvp_last_modified_time = columns.DateTime(required=False)
    event_name = columns.Text()
    event_time = columns.DateTime(required=False)
    event_url = columns.Text()
    group_topic_names = columns.Text()
    group_country = columns.Text()
    group_state = columns.Text()
    group_city = columns.Text()
    group_name = columns.Text()
    group_lon = columns.Integer()
    group_lat = columns.Integer()
    group_id = columns.Integer()

当我运行此代码时,出现以下错误:

  

Traceback(最近一次调用最后一次):文件“”,第1行,in      文件   “/Users/hpnhxxwn/anaconda/envs/magenta/lib/python2.7/site-packages/django/db/models/base.py”   第105行,       app_config = apps.get_containing_app_config(module)File“/Users/hpnhxxwn/anaconda/envs/magenta/lib/python2.7/site-packages/django/apps/registry.py”,   第237行,在get_containing_app_config中       self.check_apps_ready()文件“/Users/hpnhxxwn/anaconda/envs/magenta/lib/python2.7/site-packages/django/apps/registry.py”,   第124行,在check_apps_ready中       提升AppRegistryNotReady(“尚未加载应用程序。”)django.core.exceptions.AppRegistryNotReady:尚未加载应用程序。

有人可以建议如何继续吗?

1 个答案:

答案 0 :(得分:0)

[更新] :根据"get started section",您应该运行命令/manage.py sync_table,以便创建表格。另请查看this post(如果您还没有)。

此外,django-cassandra-engine说明可能会对您有所帮助。

您是否已在INSTALLED_APPS列表(位于settings.py文件中)中添加了应用(模型所在的位置)?

像这样(假设您的应用名为stream):

INSTALLED_APPS = [
    'django.contrib.admin',
    ...
    'stream.apps.StreamConfig',  # <-- this should be added
]

当然,之后,您应该运行./manage.py makemigrations./manage.py migrate