我正在尝试在我的应用中使用此应用https://github.com/benliles/django-chance。我的Django版本是1.9。我收到以下错误:
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
我已按照所有说明操作,但我无法弄清楚出了什么问题。请帮帮我。
答案 0 :(得分:5)
您使用的django-chance应用程序在几年内未更新,似乎不支持Django 1.9。您可以使用其他应用程序,也可以尝试更新它以使用Django 1.9。
这部分追溯显示它在signals.py
中导入__init__.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',
...
]
设置以使用您的配置。
{{1}}