将新应用程序添加到django项目时的AppRegistryNotReady

时间:2015-10-21 08:16:02

标签: python django

我正在使用django版本1.8.5 我为自己的应用创建了apps.py,我将'contact.apps.ContactConfig'添加到INSTALLED_APPS,但我仍然获得了AppRegistryNotReady

如果我没有提供足够的信息,这是我项目的链接:

https://github.com/liondancer/django-cherngloong/tree/master/server/contact

根据我的理解,我需要apps.py才能通知Django我的应用存在

项目结构:

/cherngloong
  /server
    __init__.py
    /cherngloong
      ...
      ...
      settings.py
    /contact
      __init__.py
      app.py

cherngloong /服务器/接触/ apps.py

from django.apps import AppConfig

class ContactConfig(AppConfig):
    name = "contact"
    verbose_name = "Contact"

/cherngloong/server/cherngloong/settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'webpack_loader',
    'contact.apps.ContactConfig'
)

我尝试将'contact'放入我的INSTALLED_APPS,但我得到了同样的错误。但是,如果我注释掉'contact'我的服务器运行

回溯:

$ ./manage.py runserver
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
    utility.execute()
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/core/management/__init__.py", line 343, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/core/management/__init__.py", line 177, in fetch_command
    commands = get_commands()
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
    result = user_function(*args, **kwds)
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/core/management/__init__.py", line 72, in get_commands
    for app_config in reversed(list(apps.get_app_configs())):
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/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.

0 个答案:

没有答案