django 1.8.3。 django.core.exceptions.AppRegistryNotReady:尚未加载模型

时间:2015-07-10 23:34:09

标签: python-2.7 django-models postgresql-9.4 django-oscar

我知道这些错误已被广泛讨论,但我似乎无法解决它。我已经让其他朋友看一下,但是我的django oscar项目没有任何效果。

运行python manage.py migrate

时出现此错误

版本: django 1.8.3 Python 2.7

  Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/Main/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/Main/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
    settings.INSTALLED_APPS
  File "/Users/Main/env/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/Users/Main/env/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/Main/env/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/Main/Desktop/myproject/myproject/settings.py", line 108, in <module>
    from oscar.app import application
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/app.py", line 12, in <module>
    class Shop(Application):
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/app.py", line 15, in Shop
    catalogue_app = get_class('catalogue.app', 'application')
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 29, in get_class
    return get_classes(module_label, [classname])[0]
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 86, in get_classes
    oscar_module = _import_module(oscar_module_label, classnames)
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 121, in _import_module
    return __import__(module_label, fromlist=classnames)
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/apps/catalogue/app.py", line 5, in <module>
    from oscar.apps.catalogue.reviews.app import application as reviews_app
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/apps/catalogue/reviews/app.py", line 8, in <module>
    class ProductReviewsApplication(Application):
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/apps/catalogue/reviews/app.py", line 12, in ProductReviewsApplication
    detail_view = get_class('catalogue.reviews.views', 'ProductReviewDetail')
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 29, in get_class
    return get_classes(module_label, [classname])[0]
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 86, in get_classes
    oscar_module = _import_module(oscar_module_label, classnames)
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 121, in _import_module
    return __import__(module_label, fromlist=classnames)
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/apps/catalogue/reviews/views.py", line 13, in <module>
    ['ProductReviewForm', 'VoteForm', 'SortReviewsForm'])
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 86, in get_classes
    oscar_module = _import_module(oscar_module_label, classnames)
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 121, in _import_module
    return __import__(module_label, fromlist=classnames)
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/apps/catalogue/reviews/forms.py", line 5, in <module>
    Vote = get_model('reviews', 'vote')
  File "/Users/Main/env/lib/python2.7/site-packages/oscar/core/loading.py", line 235, in get_model
    return apps.get_model(app_label, model_name)
  File "/Users/Main/env/lib/python2.7/site-packages/django/apps/registry.py", line 199, in get_model
    self.check_models_ready()
  File "/Users/Main/env/lib/python2.7/site-packages/django/apps/registry.py", line 131, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

我的manage.py文件看起来像这样

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

我是django和奥斯卡的新手。任何建议将不胜感激

0 个答案:

没有答案