2016-03-04 50 views
0

我試圖在我的應用程序中使用此應用程序https://github.com/benliles/django-chance。我的Django版本是1.9。我收到以下錯誤:Django 1.9:django.core.exceptions.AppRegistryNotReady:應用程序尚未加載

python manage.py runserver 
Unhandled exception in thread started by <function wrapper at 0x7f4931ce85f0> 
Traceback (most recent call last): 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run 
    autoreload.raise_last_exception() 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception 
    six.reraise(*_exception) 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate 
    app_config = AppConfig.create(entry) 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/apps/config.py", line 90, in create 
    module = import_module(entry) 
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/home/bewithaman/Projects/Event-Management-System/chance/__init__.py", line 1, in <module> 
    from chance import signals 
    File "/home/bewithaman/Projects/Event-Management-System/chance/signals.py", line 7, in <module> 
    from chance.models import Registration 
    File "/home/bewithaman/Projects/Event-Management-System/chance/models.py", line 2, in <module> 
    from django.contrib.auth.models import User 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in <module> 
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 49, in <module> 
    class AbstractBaseUser(models.Model): 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/db/models/base.py", line 94, in __new__ 
    app_config = apps.get_containing_app_config(module) 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/apps/registry.py", line 239, in get_containing_app_config 
    self.check_apps_ready() 
    File "/home/bewithaman/Projects/ems/local/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready 
    raise AppRegistryNotReady("Apps aren't loaded yet.") 
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 

網站的文件樹: -

├── chance 
│   ├── admin.py 
│   ├── admin.pyc 
│   ├── forms.py 
│   ├── forms.pyc 
│   ├── __init__.py 
│   ├── __init__.pyc 
│   ├── migrations 
│   │   ├── 0001_initial.py 
│   │   ├── 0002_add_eventchoice_allow_multiple.py 
│   │   ├── 0002_add_eventchoice_allow_multiple.pyc 
│   │   ├── 0003_add_created_and_label.py 
│   │   ├── 0004_add_registration_owner.py 
│   │   ├── __init__.py 
│   │   └── __init__.pyc 
│   ├── models.py 
│   ├── models.pyc 
│   ├── signals.py 
│   ├── signals.pyc 
│   ├── templates 
│   │   └── chance 
│   │    ├── event_detail.html 
│   │    ├── event_list.html 
│   │    ├── registration_email_manager_subject.txt 
│   │    ├── registration_email_subject.txt 
│   │    ├── registration_email.txt 
│   │    └── registration_form.html 
│   ├── urls.py 
│   ├── urls.pyc 
│   ├── views.py 
│   └── views.pyc 
├── EMS 
│   ├── __init__.py 
│   ├── __init__.pyc 
│   ├── settings.py 
│   ├── settings.pyc 
│   ├── urls.py 
│   ├── urls.pyc 
│   ├── wsgi.py 
│   └── wsgi.pyc 
├── manage.py 
├── media 
│   └── profile_images 
│    ├── 20140810_175920.jpg 
│    ├── IMG-20150215-WA0013.jpg 
│    ├── IMG-20150215-WA0015.jpg 
│    ├── IMG-20150215-WA0018-1.jpg 
│    ├── IMG-20150304-WA0005.jpg 
│    └── Shubham_20140216_234708-1.jpg 
├── notifications 
│   ├── admin.py 
│   ├── admin.pyc 
│   ├── apps.py 
│   ├── apps.pyc 
│   ├── __init__.py 
│   ├── __init__.pyc 
│   ├── migrations 
│   │   ├── 0001_initial.py 
│   │   ├── 0001_initial.pyc 
│   │   ├── __init__.py 
│   │   └── __init__.pyc 
│   ├── models.py 
│   ├── models.pyc 
│   ├── signals.py 
│   ├── signals.pyc 
│   ├── static 
│   │   └── notifications 
│   │    └── notify.js 
│   ├── templates 
│   │   └── notifications 
│   │    ├── list.html 
│   │    ├── notice.html 
│   │    └── test_tags.html 
│   ├── templatetags 
│   │   ├── __init__.py 
│   │   ├── __init__.pyc 
│   │   ├── notifications_tags.py 
│   │   └── notifications_tags.pyc 
│   ├── tests 
│   │   ├── __init__.py 
│   │   ├── settings.py 
│   │   ├── static 
│   │   │   └── notifications 
│   │   │    └── live-test.js 
│   │   ├── templates 
│   │   │   └── test_live.html 
│   │   ├── tests.py 
│   │   ├── urls.py 
│   │   └── views.py 
│   ├── urls.py 
│   ├── urls.pyc 
│   ├── utils.py 
│   ├── utils.pyc 
│   ├── views.py 
│   └── views.pyc 
├── registeration 
│   ├── admin.py 
│   ├── admin.pyc 
│   ├── forms.py 
│   ├── forms.pyc 
│   ├── __init__.py 
│   ├── __init__.pyc 
│   ├── migrations 
│   │   ├── 0001_initial.py 
│   │   ├── 0001_initial.pyc 
│   │   ├── 0002_auto_20160211_1250.py 
│   │   ├── 0002_auto_20160211_1250.pyc 
│   │   ├── 0003_event_participants.py 
│   │   ├── 0003_event_participants.pyc 
│   │   ├── __init__.py 
│   │   └── __init__.pyc 
│   ├── models.py 
│   ├── models.pyc 
│   ├── tests.py 
│   ├── urls.py 
│   ├── urls.pyc 
│   ├── views.py 
│   └── views.pyc 
├── static 
│   ├── css 
│   │   ├── bootstrap.css 
│   │   ├── bootstrap-fluid-adj.css 
│   │   ├── bootstrap.min.css 
│   │   ├── bootstrap-responsive.css 
│   │   └── bootstrap-responsive.min.css 
│   ├── img 
│   │   ├── glyphicons-halflings.png 
│   │   ├── glyphicons-halflings-white.png 
│   │   └── twd.ico 
│   └── js 
│    ├── bootstrap.js 
│    ├── bootstrap.min.js 
│    ├── jquery-2.0.3.js 
│    ├── jquery-2.0.3.min.js 
│    └── rango-ajax.js 
└── templates 
    └── registeration 
     ├── base.html 
     ├── events.html 
     ├── index.html 
     ├── login.html 
     ├── profile.html 
     └── register.html 

我按照所有的指示,但我無法弄清楚什麼是錯的。請幫幫我。

回答

5

您正在使用的django-chance應用程序在幾年內未更新,似乎並不支持Django 1.9。您可以改用其他應用程序,或者嘗試更新它以使用Django 1.9。

回溯的這部分內容顯示它在__init__.py中導入signals.py,它試圖在加載應用程序之前導入模型。

File "/home/bewithaman/Projects/Event-Management-System/chance/__init__.py", line 1, in <module> 
    from chance import signals 
    File "/home/bewithaman/Projects/Event-Management-System/chance/signals.py", line 7, in <module> 
    from chance.models import Registration 

chance/__init__.py文件中刪除此行

from chance import signals 

然後創建一個change/apps.py文件,並定義導入信號在ready()方法的應用程序配置類。

from django.apps import AppConfig 

class ChanceConfig(AppConfig): 

    def ready(self): 
     from . import signals 

最後,更新您的INSTALLED_APPS設置以使用您的配置。

INSTALLED_APPS = [ 
    ... 
    'chance.apps.ChanceConfig', 
    ... 
] 
+0

Thanks @Alasdair – bewithaman

相關問題